- Home /
OnTriggerEnter2D not detecting.
I have a player sprite set up that shoots a projectile, I created a new sprite for a enemy which I then wanted to be destroyed upon collision with the projectile... basic stuff. The projectile nor the enemy object is destroyed upon impact and using Debug.Log doesn't get any output upon the collision. I dunno if its even reading the collision.
Heres the script I have set up, I double checked colliders and rigidbodies (isKinematic is unchecked) and I can't figure out if I've missed something. I'm relatively new to Unity and have been following the official tutorial videos which for the most part I've been able to convert from 3D to 2D to only now run into a snag with this problem. I feel like its something obvious I'm overlooking. Any help would be great.
public class destroyer : MonoBehaviour
{
void OnTriggerEnter2D(Collider2D other)
{
Debug.Log (other.name);
if (other.gameObject.tag == "Boundary")
{
return;
}
Destroy(other.gameObject);
Destroy(gameObject);
}
}
Answer by emonegarand · Jan 13, 2014 at 06:59 PM
I figured out the issue, it was a collider oversight on my part. I just removed the collider and rigidbody from my parent empty GameObject and just used the colliders on the child object. Works just like it should now.