Rigidbody

A Rigidbody is the main component that allows game objects to engage in physical behavior (that is, movement). When a Rigidbody is attached to a GameObject, the object will immediately respond to gravity. Since a Rigidbody takes over the movement of the GameObject it is attached to, you shouldn't try to move it from a script by changing the Transform properties such as position, rotation, or scale. Instead, you should apply forces to push (for example, other characters, objects, projectiles) the GameObject and let the physics engine calculate the results. There are some cases where you might want a GameObject to have a Rigidbody without having its motion controlled by the physics engine. For example, you may want to control your character directly from script code but still, allow it to be detected by triggers. This kind of non-physical motion produced from a script is known as kinematic motion. The Rigidbody component has a property called Is Kinematic that removes it from the control of the physics engine and allows it to be moved kinematically from a script. It is possible to change the value of Is Kinematic from a script to allow physics to be switched on and off for an object, but this comes with a performance overhead and should be used sparingly.

If one or more Collider components are also added, the GameObject is moved by incoming collisions. We discuss Collider components in the next section.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset