events - How can I check if there is a collision? -


in game, have ball , ground. ball falling , collides ground.

but how can check if ball has collided? i've added script ball, , got following code:

void oncollisionenter (collision collisioninfo)  {     print ("collision!");     destroy(this); } 

problem nothing happens, using wrong event? want trigger animation.

your code work if using 3d colliders. however, since you're using 2d, there's separate event called oncollisionenter2d, change event this:

void oncollisionenter2d (collision2d collisioninfo)  {     print ("collision!");     destroy(this); } 

Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -