private void OnTriggerEnter2D(Collider2D collision)
{
if (collision.tag == “Top_Wall”)
{
attack = false;
}
if (collision.tag == “Enemy”)
{
attack = false;
}
}
I had a similar issue, I used OnCollisionEntry2D(Collision2D collision)
Instead of OnTriggerEnter.
For that to work you have to uncheck the box “OnTrigger”. I’m not sure that it will work for you but you can try. Let me know if it works for you !
I figure out that, if I don’t want to pass through objects in a collision then I have to use OnCollision otherwise
trigger.
Sorry for these basic questions. And thanks for your answer
private void OnCollisionEnter2D(Collision2D collision)
{
if (collision.gameObject.tag == "Top_Wall")
{
attack = false;
}
if (collision.gameObject.tag == "Enemy")
{
attack = false;
}
}