OnCollisionEnter2D() and OnTriggerEnter2D() not logging to console

image
Don’t mind my Portuguese script title :upside_down_face:

I’m using Unity 4.7.2f1

Expected Behavior
It’s supposed to print to the console “trigger” or “collision”.

Observed Behavior
Nothing gets logged to the console, neither “trigger” or “collision”, although the ball and the collider do interact when “Is Trigger” isn’t ticked.

What I’ve tried
I have seen similar discussions that were already solved, but nothing from them worked, I made sure the ball and the collider were on the same z coordinate, the colliders were both 2D, that I typed it correctly, that all brackets were closed and I tried changing “print” to “Debug.Log”.

You need to use Collider2D instead of trigger in the OnTriggerEnter2D arguments

Like this?? image

It didn’t work…

Oh my goodness, sorry, saw the wrong thing, tired eyes I guess. The code seems to be alright, if the objects does interact with each other, try to make sure the script is actually attached to the object and that the collider is actually 2d and not 3d

1 Like

Whoops, I attached it to the ball accidentally, thanks for the help!

Edit: Whoa it works on the ball too, I guess I unattached it to test because I had something else wrong and forgot to attach it again lol.

1 Like

Glad to know that it is working now :slight_smile: