Version: 2018.2

Rigidbody2D

class in UnityEngine

/

Inherits from:Component

Switch to Manual

Description

Физический компонент твердого тела для 2D спрайтов.

The Rigidbody2D class essentially provides the same functionality in 2D that the Rigidbody class provides in 3D. Adding a Rigidbody2D component to a sprite puts it under the control of the physics engine. By itself, this means that the sprite will be affected by gravity and can be controlled from scripts using forces. By adding the appropriate collider component, the sprite will also respond to collisions with other sprites. This behaviour comes entirely from Unity's physics system; very little code is required to get impressive and authentic physical behaviour and allows for "emergent" gameplay that was not explicitly coded into the game.

См. также: Rigidbody класс, SpriteRenderer класс, Collider2D класс, Joint2D класс.

Variables

angularDragКоэффициент углового торможения.
angularVelocityУгловая скорость в градусах в секунду.
attachedColliderCountReturns the number of Collider2D attached to this Rigidbody2D.
bodyTypeПозиция твердого тела.
centerOfMassЦентр масс твердого тела в локальном пространстве.
collisionDetectionModeМетод, используемый физическим движком для проверки столкновения между двумя объектами.
constraintsControls which degrees of freedom are allowed for the simulation of this Rigidbody2D.
dragКоэффициент торможения.
freezeRotationКонтролирует будет ли физика изменять вращение объекта.
gravityScaleУровень того, на сколько данный объект подвержен гравитации.
inertiaИнерция вращающегося твердого тела.
interpolationИнтерполяция физики, использующаяся между обновлениями.
isKinematicДолжно ли данное твердое тело выйти из под контроля физики?
massMass of the Rigidbody.
positionПозиция твердого тела.
rotationВращение твердого тела.
sharedMaterialThe PhysicsMaterial2D that is applied to all Collider2D attached to this Rigidbody2D.
simulatedУказывает, должно ли твердое тело имитироваться физической системой.
sleepModeСостояние сна, в которое погружается твердое тело при инициализации.
useAutoMassShould the total rigid-body mass be automatically calculated from the [[Collider2D.density]] of attached colliders?
useFullKinematicContactsShould kinematic/kinematic and kinematic/static collisions be allowed?
velocityЛинейная скорость твердого тела.
worldCenterOfMassПолучает центр масс твердого тела в глобальном пространстве.

Public Functions

AddForceПрименяет силу к твердому телу.
AddForceAtPositionСила применяется к данной позиции пространства.
AddRelativeForceДобавляет силу к rigidbody2D относительно его системы координат.
AddTorqueПрименяет крутящий момент к центру масс твердого тела.
CastAll the Collider2D shapes attached to the Rigidbody2D are cast into the scene starting at each collider position ignoring the colliders attached to the same Rigidbody2D.
DistanceCalculates the minimum distance of this collider against all Collider2D attached to this Rigidbody2D.
GetAttachedCollidersReturns all Collider2D that are attached to this Rigidbody2D.
GetContactsRetrieves all contact points for all of the collider(s) attached to this rigidbody.
GetPointПолучает локальную точку пространства с учетом точки в глобальном пространстве твердого тела.
GetPointVelocityСкорость твердого тела в точке глобального пространства.
GetRelativePointПолучает точку глобального пространства с учетом точки /relativePoint - относительной точки/ в локальном пространстве твердого тела.
GetRelativePointVelocityСкорость твердого тела в точке локального пространства.
GetRelativeVectorПолучает вектор глобального пространства с учетом вектора /relativeVector - относительного вектора/ в локальном пространстве твердого тела.
GetVectorПолучает вектор локального пространства с учетом вектора твердого тела в глобальном пространстве твердого тела.
IsAwakeТвердое тело "проснулось"?
IsSleepingТвердое тело "спит"?
IsTouchingChecks whether the collider is touching any of the collider(s) attached to this rigidbody or not.
IsTouchingLayersChecks whether any of the collider(s) attached to this rigidbody are touching any colliders on the specified layerMask or not.
MovePositionПередвигает твердое тело в позицию.
MoveRotationВращение твердого дела на угол.
OverlapColliderGet a list of all colliders that overlap all colliders attached to this Rigidbody2D.
OverlapPointCheck if any of the Rigidbody2D colliders overlap a point in space.
SleepПогружает твердое тело в "сон".
WakeUpОтключает состояние "сна" у твердого тела.

Inherited members

Variables

gameObjectИгровой объект к которому прикреплён данный компонент. Компонент всегда прикреплён к игровому объекту.
tagТег данного игрового объекта.
transformThe Transform attached to this GameObject.
hideFlagsShould the object be hidden, saved with the Scene or modifiable by the user?
nameThe name of the object.

Public Functions

BroadcastMessageВызывает метод названный methodName на каждом MonoBehaviour этого game object-а или любого из его потомков.
CompareTagПомечен ли данный игровой объект тегом tag?
GetComponentВозвращает компонент типа type, если он прикреплен к игровому объекту и null, если не прикреплен.
GetComponentInChildrenВозвращает компонент типа type в GameObject или некоторого его потомка через поиск в глубину.
GetComponentInParentВозвращает все компоненты типа type из GameObject'а или из любого его родителя.
GetComponentsВозвращает все компоненты типа type в GameObject.
GetComponentsInChildrenВозвращает все компоненты типа type в GameObject или любому из его потомков.
GetComponentsInParentВозвращает все компоненты типа type в GameObject или любому из его родителей.
SendMessageВызывает метод с названием methodName в каждом MonoBehaviour в этом игровом объекте.
SendMessageUpwardsВызывает метод с именем methodName в каждом MonoBehaviour в этом игровом объекте и в каждом предке поведения.
GetInstanceIDReturns the instance id of the object.
ToStringReturns the name of the GameObject.

Static Functions

DestroyУдаляет GameObject, Component или Asset.
DestroyImmediateDestroys the object obj immediately. You are strongly recommended to use Destroy instead.
DontDestroyOnLoadDo not destroy the target Object when loading a new Scene.
FindObjectOfTypeReturns the first active loaded object of Type type.
FindObjectsOfTypeReturns a list of all active loaded objects of Type type.
InstantiateClones the object original and returns the clone.

Operators

boolDoes the object exist?
operator !=Compares if two objects refer to a different object.
operator ==Compares two object references to see if they refer to the same object.