In real-world physics, a rigid body is any physical body that does not deform or change shape under physics forces. The distance between any two given points of a rigid body remains constant in time, regardless of external forces exerted on it.
To simulate physics-based behavior such as movement, gravity, collisionA collision occurs when the physics engine detects that the colliders of two GameObjects make contact or overlap, when at least one has a Rigidbody component and is in motion. More info
See in Glossary, and joints, you need to configure items in your sceneA Scene contains the environments and menus of your game. Think of each unique Scene file as a unique level. In each Scene, you place your environments, obstacles, and decorations, essentially designing and building your game in pieces. More info
See in Glossary as rigid bodies. To configure GameObjectsThe fundamental object in Unity scenes, which can represent characters, props, scenery, cameras, waypoints, and more. A GameObject’s functionality is defined by the Components attached to it. More info
See in Glossary as rigid bodies in Unity’s PhysX system, you can assign them the RigidbodyA component that allows a GameObject to be affected by simulated gravity and other forces. More info
See in Glossary component. The Rigidbody component is represented in the API by the
In Unity, a Rigidbody component provides a physics-based way to control the movement and position of a GameObject. Instead of the Transform properties, you can use simulated physics forces and torque to move the GameObject, and let the physics engineA system that simulates aspects of physical systems so that objects can accelerate correctly and be affected by collisions, gravity and other forces. More info
See in Glossary calculate the results.
In most cases, if a GameObject has a Rigidbody, you should use the Rigidbody properties to move the GameObject, instead of the Transform properties. The Rigidbody properties apply forces and torque from the physics system, which change the GameObject’s Transform; if you then change the Transform directly, Unity cannot correctly calculate the physics simulation, and you might see unwanted behavior. This is particularly true of rigid bodies with JointsA physics component allowing a dynamic connection between Rigidbody components, usually allowing some degree of movement such as a hinge. More info
See in Glossary.
Unity handles physics-based movement globally, not locally. When a GameObject with a Rigidbody moves via physics-based movement, it moves independently of any parent or child GameObject. A child GameObject that has a Rigidbody still uses its parent GameObject to define its local position for initialization, but Unity calculates its physics-based movement in global space.
There are some cases where you might want the physics system to detect a GameObject, but not to control it. For example, you might want CollidersAn invisible shape that is used to handle physical collisions for an object. A collider doesn’t need to be exactly the same shape as the object’s mesh - a rough approximation is often more efficient and indistinguishable in gameplay. More info
See in Glossary to detect a GameObject, but you intend to control that GameObject’s movement and position via its Transform.
Movement in Unity that is not physics-based is called kinematic motion. The Rigidbody component has the property Is Kinematic which, when enabled, defines the attached GameObject as non-physics-based, and removes it from the control of the physics engine. This allows you to move it kinematically via the Transform without Unity’s physics simulation calculations overriding the changes.
A kinematic Rigidbody can apply physics-based force to physics-based Rigidbody GameObjects, but does not receive physics-based force. For example, a kinematic Rigidbody can collide with and “push” a Rigidbody that has physics-based movement, but a Rigidbody with physics-based movement cannot “push” a kinematic Rigidbody.
If you use a Joint to attach a kinematic Rigidbody to a non-kinematic Rigidbody, the Joint cannot exert forces to move the kinematic Rigidbody. It can only ever move the non-kinematic Rigidbody. However, you can still move the kinematic Rigidbody via the Transform, and the Joint can adjust the pose of the non-kinematic body to satisfy the joint limits.
When a Rigidbody moves at a slower speed than the Sleep Threshold (see the Physics Project Settings), Unity sets the Rigidbody to “sleep”, which means that the physics system does not include it in physics calculations. When a sleeping Rigidbody receives a collision or force, Unity “wakes up” the Rigidbody and continues to include it in physics calculations.
By default, the sleeping and waking of a Rigidbody component happens automatically.
However, you can also control this behavior yourself via script, via the methods
A Rigidbody might fail to wake up in response to movement and collisions from static colliders (that is, colliders without a Rigidbody) that are moving via the Transform position instead of the physics system. This is particularly likely if the physics system can no longer detect the static collider. If this happens, you can use
Rigidbody.WakeUp to wake up the sleeping Rigidbody.
For more information on how the PhysX physics system handles sleeping, see the NVIDIA PhysX SDK Rigidbody Dynamics documentation on Sleeping.