Answer the question
In order to leave comments, you need to log in
Destroy doesn't work. Why is that?
I'm making a simple platformer where you need to collect stars on Unity. When a character touches a star, the star does not disappear. I send a function where Destroy does not work.
Note: Is Trigger in collider set.
void OnTriggerEnter2D(Collider2D col)
{
if (col.GetComponent<PolygonCollider2D>().tag == "star")
{
Destroy(col.gameObject);
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question