Since our player has a Rigidbody component attached, we should let the physics engine control our movement instead of manually translating and rotating the Transform. There are two options when it comes to applying force:
- You can do it directly by using Rigidbody class methods such as AddForce and AddTorque to move and rotate an object, respectively. This approach has its drawbacks and often requires additional code to compensate for unexpected physics behavior.
- Alternatively, you can use other Rigidbody class methods such as MovePosition and MoveRotation, which still use applied force but take care of edge cases behind the scenes.Â
We'll take the second route in the next section, but if you're curious about manually applying force and torque to your GameObjects, then start here:Â https://docs.unity3d.com/ScriptReference/Rigidbody.AddForce.html.
Either of these will give the player a more lifelike feel and...