Answer the question
In order to leave comments, you need to log in
onTriggerEnter2D and onCollisionEnter2D don't work, what could be wrong?
when entering the trigger, onTriggerEnter2D does not work, the same situation with onCollisionEnter2D
code onTriggerEnter:
public void onTriggerEnter2D(Collision2D coll)
{
Debug.Log("Enter");
if(coll.gameObject.name == "bonus")
{
Destroy(coll.gameObject);
score++;
}
}
public void onCollisionEnter2D(Collision2D col)
{
if (col.gameObject.tag == "enemy")
{
NewBehaviourScript im = col.gameObject.GetComponent<NewBehaviourScript>();
im.Death();
}
}
public void Death()
{
if(isAlive)
{
anim.SetBool("isAlive",false);
speed = 0;
transform.GetComponent<Collider2D>().enabled = false;
isAlive = false;
}
}
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