1
\$\begingroup\$

I'm making a 2D sidescrolling game in Unity where the player shoots at obstacles while running. But nothing I try seems to get the collision detection to work. This is the obstacle script:

void onCollisionEnter2D(Collision2D col)
{
    if (col.gameObject.tag == "circle")
                    Destroy (gameObject);
    }

the circle tag refers to the projectile being shot at the obstacle

\$\endgroup\$
1
\$\begingroup\$

It should be void OnCollisionEnter2D(){} And if that's not the case (if you just mistyped that here) Make sure you have a rigid-body attached to one of your game objects and make sure both colliding objects have 2d colliders.

Cheers, Demetry Romanowski

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.