Introduction to Rigidbody Physics in Unity
The Unity Engine has intricate physics capabilities that simulate real-world forces such as gravity, velocity, and acceleration.
How can I add physics to my object?
Physics can be applied to an object through the use of a Rigidbody Component.
Let’s take a look at the Rigibody properties
- Mass is the tendency of an object to resist changing its state of motion, known as inertia. By default, the world gravity of the Unity Engine is set to -9.81, which is equivalent to the earth's gravitational pull of 9,807 m/s².
You can always verify this, and all default physics via:
Edit → Project Settings → Physics
Due to the aforementioned inertia, the more mass you add to an object, the slower its movement will be when using a physics-dependent method like AddForce to move your object. This is the object resisting the applied force.
Using AddForce to Jump
However, note that this does not apply to an object in freefall motion where the amount of mass has no effect on the gravitational pull. Gravity is enabled by tweaking the “Use Gravity” box.
- Drag(wind resistance): Dampens velocity over time and angular drag affects angular velocity.
- The is Kinematic checkbox: Enables the Rigibody to affect outer objects but will not affect the holder itself(it will register collision but or forces). If a Rigidbody is kinematic, you can control its actions with a script, and Unity will not automatically apply any physics to that object. is kinematic also affect objects in the Animation Engine.
- Interpolate: Movements in animation are smoothed by taking the information from the previous frame in the animation timeline.
- Extrapolation: Movements in animation are smoothed through a guess or approximation of the next frame.
- Collision: A dropdown menu with options to set the detection rate for collision
- Discrete: Default.
- Continuous: Collision between fast object and static objects.
- Continuous Dynamic: Collisions between fast objects.
- Continuous Speculative: Predictive collisions
- The Constraints checkboxes: Used to restrain movements in a given axis or set of axes.
In my next article, I will address the difference between OnCollisionEnter and OnTriggrerEnter, and when you should use them.