- Home /
Question by
DrGreenthumbs92 · Dec 07, 2017 at 09:07 PM ·
2dcolliderontriggerenterdestroy objectchild object
2d edge collider wont destroy?
hey guys, so I have an empty gameObject that has a number of child objects, there is a sprite, a sprite mask and 5 separate edge colliders. What i'm trying to do is destroy whatever collider my trigger hits on mouse click, the trigger is attached to a child of the character along with the offending script. I have put some debugs in and the one in the OnTriggerEnter returns a hit but the one in the if statement does not. i thought this was going to be a simple few lines of code but i seem to be missing something. I'm not well versed in 2d code so assistance would be lovely.
void OnTriggerEnter2D(Collider2D other)
{
Debug.Log("Hit");
if (Input.GetMouseButton(0))
{
Debug.Log("Hit2");
Destroy(gameObject);
}
}
Comment