[Solved] OnCollisionEnter2D() and OnTriggerEnter2D() not triggering in console

OnCollisionEnter2D() and OnTriggerEnter2D() are not logging to the console when the ball object lands or passes through the lose collider.

I’ve tried going over the course again.
Checked for syntax errors.

Screen shots:



1 Like

Hi,

Check your Z indexes :slight_smile:

How?

1 Like

Nevermind that fixed my problem! Thanks

1 Like

Sorry, I should have given more info… I assumed you’d see it on the screenshots also :slight_smile:

So yes, whilst you are developing a 2D game, you are still effectively in a 3D world, the Z index of the Transform components on GameObjects is still very important. In this case, as you will have seen now, the Lose Collider was at -10, and the Ball was at 10. So whilst from a 2D perspective they may have looked like they were colliding, the were actually 20 units apart on the Z index and thus didn’t make contact.

Sorry I didn’t give more info in my first response :slight_smile:

1 Like

Privacy & Terms