How to make attacker ignore defender's death animation

Hello ,
I am facing the same problem.
When the attacker kills the defender . The defender plays the death animation.But
attacker does not pass until the defender completely destroy.
I have Destroy the Box Collider of defender as well when die .
But also attacker does not pass until the defender destroy.
Please somebody help me

if(health<=0)
{
  GetComponent<Animator>().SetTrigger("Die");
                 
                    Destroy(gameObject.GetComponent<BoxCollider2D>());

                    Destroy(healthBar.gameObject);
                    Destroy(gameObject, 5f);

}
     

Hi Subhit,

Does your Player have got a Rigidbody2D component attached? If so, you could simply set its simulated property to false in the else-block. This way, the Player will not be part of the physics simulation anymore.

Did this work?

Hi Nina,

Thank you for your concern.
I solved that problem by using OnTriggerStay2D instead of OnTriggerEnter2D.
And I also use OnTriggerExit2D.
:slight_smile:

Good job! :slight_smile:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms