A Rigidbody 2D component places a GameObject under the control of the physics engine. Many concepts familiar from the standard Rigidbody component carry over to Rigidbody 2D; the differences are that in 2D, objects can only move in the XY plane and can only rotate on an axis perpendicular to that plane.
|Use Auto Mass||Check this box if you want the Rigidbody 2D to automatically detect and assume the GameObject’s mass from its Collider 2D.|
|Mass||Mass of the Rigidbody 2D. This is greyed out if you have selected Use Auto Mass.|
|Linear Drag||Drag coefficient affecting positional movement.|
|Angular Drag||Drag coefficient affecting rotational movement.|
|Gravity Scale||Degree to which the GameObject is affected by gravity.|
|Is Kinematic||Check this if you want the Rigidbody 2D to be affected and moved by forces and collisions. See Kinematic Rigidbody 2D components, below, for more details.|
|Interpolate||How the GameObject’s movement is interpolated between physics updates (useful when motion tends to be jerky).|
|None||No movement smoothing is applied.|
|Interpolate||Movement is smoothed based on the GameObject’s positions in previous frames.|
|Extrapolate||Movement is smoothed based on an estimate of its position in the next frame.|
|Sleeping Mode||How the object “sleeps” to save processor time when it is at rest.|
|Never Sleep||Sleeping is disabled. This option should be avoided where possible, as it can be very demanding on resources at run time.|
|Start Awake||GameObject is initially awake.|
|Start Asleep||GameObject is initially asleep but can be woken by collisions.|
|Collision Detection||How collisions with other objects are detected.|
|Discrete||A collision is registered only if the GameObject’s Collider 2D is in contact with another during a physics update.|
|Continuous||A collision is registered if the GameObject’s Collider 2D appears to have contacted another between updates.|
|Constraints||Restrictions on the Rigidbody 2D’s motion.|
|Freeze Position||Stops the Rigidbody 2D moving in the world’s x and y axes selectively.|
|Freeze Rotation||Stops the Rigidbody 2D rotating around the world’s z axis selectively.|
Usually, the Unity Editor’s Transform component defines how a GameObject (and its child GameObjects) is positioned, rotated and scaled within the Scene. When it is changed, it updates other components, which may update things like where they render or where colliders are positioned. The 2D physics engine is able to move colliders and make them interact with each other, so a method is required for the physics engine to communicate this movement of colliders back to the Transform components. This movement and connection with colliders is what a Rigidbody 2D component is for.
The Rigidbody 2D component overrides the Transform and updates it to a position/rotation defined by the Rigidbody 2D. Note that while you can still override the Rigidbody 2D by modifying the Transform component yourself (because Unity exposes all properties on all components), doing so will cause problems such as GameObjects passing through or into each other, and unpredictable movement.
Any Collider 2D component added to the same GameObject or child GameObject is implicitly attached to that Rigidbody 2D. When a Collider 2D is attached to the Rigidbody 2D, it moves with it. A Collider 2D should never be moved directly using the Transform or any collider offset; the Rigidbody 2D should be moved instead. This offers the best performance and ensures correct collision detection. Collider 2Ds attached to the same Rigidbody 2D won’t collide with each other. This means you can create a set of colliders that act effectively as a single compound collider, all moving and rotating in sync with the Rigidbody 2D.
When designing a Scene, you are free to use a default Rigidbody 2D and start attaching colliders. These colliders allow any other colliders attached to different Rigidbody 2Ds to collide with each other.
Adding a Rigidbody 2D allows a sprite to move in a physically convincing way by applying forces from the scripting API. When the appropriate collider component is also attached to the sprite GameObject, it is affected by collisions with other moving GameObjects. Using physics simplifies many common gameplay mechanics and allows for realistic behavior with minimal coding.
The Is Kinematic setting switches off the physical behaviour of the Rigidbody 2D so that it will not react to gravity and collisions. This is typically used to keep a GameObject under non-physical script control most of the time, but then switch to physics in a particular situation. For example, a player might normally move by walking (better handled without physics) but then get catapulted into the air by an explosion or strike (better handled with physics). Physics can be used to create the catapulting effect if you switch off Is Kinematic just before applying a large force to the GameObject.