class in UnityEngine
Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.Close
For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.Close
Rigidbody physics component for 2D sprites.
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.
See Also: Rigidbody class, SpriteRenderer class, Collider2D class, Joint2D class.
|Coefficient of angular drag.
|Angular velocity in degrees per second.
|Returns the number of Collider2D attached to this Rigidbody2D.
|The physical behaviour type of the Rigidbody2D.
|The center of mass of the rigidBody in local space.
|The method used by the physics engine to check if two objects have collided.
|Controls which degrees of freedom are allowed for the simulation of this Rigidbody2D.
|Coefficient of drag.
|Controls whether physics will change the rotation of the object.
|The degree to which this object is affected by gravity.
|The rigidBody rotational inertia.
|Physics interpolation used between updates.
|Should this rigidbody be taken out of physics control?
|Mass of the Rigidbody.
|The position of the rigidbody.
|The rotation of the rigidbody.
|The PhysicsMaterial2D that is applied to all Collider2D attached to this Rigidbody2D.
|Indicates whether the rigid body should be simulated or not by the physics system.
|The sleep state that the rigidbody will initially be in.
|Should the total rigid-body mass be automatically calculated from the [[Collider2D.density]] of attached colliders?
|Should kinematic/kinematic and kinematic/static collisions be allowed?
|Linear velocity of the Rigidbody in units per second.
|Gets the center of mass of the rigidBody in global space.
|Apply a force to the rigidbody.
|Apply a force at a given position in space.
|Adds a force to the rigidbody2D relative to its coordinate system.
|Apply a torque at the rigidbody's centre of mass.
|All 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.
|Returns a point on the perimeter of all enabled Colliders attached to this Rigidbody that is closest to the specified position.
|Calculates the minimum distance of this collider against all Collider2D attached to this Rigidbody2D.
|Returns all Collider2D that are attached to this Rigidbody2D.
|Retrieves all contact points for all of the Collider(s) attached to this Rigidbody.
|Get a local space point given the point point in rigidBody global space.
|The velocity of the rigidbody at the point Point in global space.
|Get a global space point given the point relativePoint in rigidBody local space.
|The velocity of the rigidbody at the point Point in local space.
|Get a global space vector given the vector relativeVector in rigidBody local space.
|Get a local space vector given the vector vector in rigidBody global space.
|Is the rigidbody "awake"?
|Is the rigidbody "sleeping"?
|Checks whether the collider is touching any of the collider(s) attached to this rigidbody or not.
|Checks whether any of the collider(s) attached to this rigidbody are touching any colliders on the specified layerMask or not.
|Moves the rigidbody to position.
|Rotates the Rigidbody to angle (given in degrees).
|Get a list of all Colliders that overlap all Colliders attached to this Rigidbody2D.
|Check if any of the Rigidbody2D colliders overlap a point in space.
|Sets the rotation of the Rigidbody2D to angle (given in degrees).
|Make the rigidbody "sleep".
|Disables the "sleeping" state of a rigidbody.
|The game object this component is attached to. A component is always attached to a game object.
|The tag of this game object.
|The Transform attached to this GameObject.
|Should the object be hidden, saved with the Scene or modifiable by the user?
|The name of the object.
|Calls the method named methodName on every MonoBehaviour in this game object or any of its children.
|Is this game object tagged with tag ?
|Returns the component of Type type if the game object has one attached, null if it doesn't.
|Returns the component of Type type in the GameObject or any of its children using depth first search.
|Returns the component of Type type in the GameObject or any of its parents.
|Returns all components of Type type in the GameObject.
|Returns all components of Type type in the GameObject or any of its children using depth first search. Works recursively.
|Returns all components of Type type in the GameObject or any of its parents.
|Calls the method named methodName on every MonoBehaviour in this game object.
|Calls the method named methodName on every MonoBehaviour in this game object and on every ancestor of the behaviour.
|Gets the component of the specified type, if it exists.
|Returns the instance id of the object.
|Returns the name of the object.
|Removes a GameObject, component or asset.
|Destroys the object obj immediately. You are strongly recommended to use Destroy instead.
|Do not destroy the target Object when loading a new Scene.
|Returns the first active loaded object of Type type.
|Returns a list of all active loaded objects of Type type.
|Clones the object original and returns the clone.