OnCollisionEnter Vs. OnTriggerEnter — When to use them?
Adding to the physics in unity topic we have two methods we can call that effect our game objects. In my previous example i used OnTriggerEnter
Which activated the destroy game object instruction. this works because both objects have colliders components attached.
in the unity documentation is it explained like:
Both GameObjects must contain a Collider component. One must have Collider.isTrigger enabled, and contain a Rigidbody. If both GameObjects have Collider.isTrigger enabled, no collision happens. The same applies when both GameObjects do not have a Rigidbody component.
the other OnCollisionEnter can be used when collision events are only sent if one of the colliders also has a non-kinematic rigidbody attached. For example if we wanted to trigger a finishing line to trigger the end of a race. Gameobjects can pass through each other and an event can take place.