Unity Physics :
Unity have build in physics system which will do mathematical calculation, physics etc. itself and allow us to save lot more time. We have to add some physics related components to our objects to use unity’s physics system.
In unity we have to add Rigidbody and Colliders to use physics. Rigidbody component allow objects to have physics properties like gravity,mass,velocity etc. where as colliders allows us to detect collisions between objects for this we need to attach Rigidbody to any of the 2 objects which are collided.
We can use Colliders and Rigidbody for 2d as well as 3d objects. there are different shapes of colliders like box collider, sphere, wheel, capsule etc. we can use them as per our need.
In Rigidbody2D, to use gravity we need to set Gravity Scale Value to 1, else set is as 0.
In rigidbody there are options related to physics. we can edit those options and changes there values as per our need for desire output result. We can also use gravity like real life. to use it we need to check gravity option. if we don’t need gravity then simply uncheck that option.
There are also 2 types of colliders for 2d and 3d. we can use them as we need them depending upon our project is in 2d or 3d.
In both colliders type we get Edit collider option to change collider size and shape.
There is also Is Trigger option to use different type of collision option. that is Trigger and Collision.
We can choose between 2 options to detect collision between objects. In Trigger collision, object can pass through the colliders boundary but at the same time it will trigger the collision event. which inform us that collision happens.
In next article we will see about how and when to use Trigger and Collision events in unity..