Colliders and its events-
Colliders work with Rigidbodies to bring physics in Unity to life.Rigidbodies allow objects to be controlled by physics. Colliders allow objects to collide with one another.
It is necessary that when two bodies with colliders attached collide and collision takes place, one body should have rigidbody attached to it.
On collision the following messages are sent to collided body or we can say following events take place.
1) OnCollisionEnter- It occurs when two colliders start touching each other.
2) OnCollisionExit- It occurs when two colliders stop touching each other.
3) OnCollisionStay- It occurs once per frame for every collider touching other collider.
4) OnTriggerEnter- Itis called when the Collider other enters the trigger.
5) OnTriggerExit- It is called when the Collider other has stopped touching the trigger.
6) OnTriggerStay- It is called almost all the frames for every Collider other that is touching the trigger.
0 Comment(s)