- Home /
Collision2D only fired on one collider
Hello everyone,
I'm facing a weird issue here, I have a 2D scene with :
Player with rigidbody and collider
Missile with rigidbody and collider
Enemy with collider
When Player collides with enemy, collision is detected on both gameObjects, but when missile collides with enemy, collision is only detected on one side: the missile, when the missile script doesn't have a OnCollisionEnter2D function, it's detected on the ghost script.
Is it a normal behavior or a bug or maybe I'm missing something.. ?
Thank you.
Do any of these objects get destroyed upon colliding. If so it is possible that the enemy is getting destroyed before its collision code has run. One collision is always run fully before the next takes place, even if they collide at the same time one will run before the other.
Answer by Mohamed Reda · Dec 19, 2014 at 11:44 AM
Yes it actually is the case. the missile destoys itself when the collision occurs. I have resolved the issue by invoking destroy in a short period of time.
Invoke ("Explode", 0.1f);
instead of Explode();
Thank you