How do I get my enemy to detect that the Player is dead and he should just chill out! stop attacking dead people!
I have a Collision box on my policeman when he dies I disable this.
FootStopperPolice.SetActive(false);
on my enemy script I have if(other.gameObject.CompareTag("policeFootCol")) Then attack !
else if (PoliceScript.FootStopperPolice.activeSelf == false) THEN STOP ATTACKING!!!!!!!!
void OnTriggerEnter2D (Collider2D other)
{
if(other.gameObject.CompareTag("policeFootCol"))
{
moveScript.WalkSpeed = 0f;
SkelAnim.state.SetAnimation(0,attack,true);
}
else if (PoliceScript.FootStopperPolice.activeSelf == false)
{
moveScript.WalkSpeed = 1f;
SkelAnim.state.SetAnimation(0,walk,true);
}
what's happening is that the enemy just keeps attacking forever
alt text!
seem like you are using spine animator, I never used it before, but, check if you not are just setting the animation, to play it you need to change the name of animationName
on SkelAnim
, check this
Your answer
Follow this Question
Related Questions
[SOLVED] Problem with OnCollisionEnter2D script after upgrading to Unity 5.3(from Unity 4.6) 1 Answer
create object on raycast collision that follows raycast. 0 Answers
Unity 5: AddForce Increases power when already being pushed towards a collider. How to make stop? 1 Answer
Detect overlapping objects 2D game 0 Answers
Children of a hingejoint not colliding with parent's mesh when connectedBody is assigned 1 Answer