OnTriggerEnter2D v.s. OnCollisionEnter2D

· 1 min read

OnCollisionEnter2D: Some collision really happened, means two objects collide with each other.

OnTriggerEnter2D: Collision not really happened when you set up Is Trigger is true.

For example, if two objects, one with Is Trigger off (Object A), the other with Is Trigger on (Object B). So Object A can pass Object B.

Few things in order to make sure the OnTriggerEnter2D() get called on Object B.

  1. Both Object A and Object B must have the Collider
  2. Object B must have the Is Trigger on
  3. Be careful about the friction. If the Object A and Object B are two far away, Object A might cannot collide with Object B.

Unity needone OnTriggerEnter2D OnCollisionEnter2D

And that is it!