RPG Course, Stop attacking already!

Hi!

I have an issue with my animation. I recently set the stopAttack trigger but it doesn’t work! Both the player and the enemy continuously attack. When i move it doesn’t cancel the attack animation, it just attacks while i’m moving. When i manually press the stopAttack trigger, nothing happens. Any fixes for this?

@nina

Compare the string you’re using to SetTrigger() to the name of the trigger very carefully. Remember that it’s case sensitive.

1 Like

Hi!

It all matches. I did some research online and a few people have had this issue. I haven’t found any fixes for it.

 private void StopAttack()
  {
     GetComponent<Animator>().ResetTrigger("attack");
     GetComponent<Animator>().SetTrigger("stopAttack");
  }
}

Make sure that the transition with the stopAttack trigger has the “has exit time” unchecked.

It does on the next one down and has the triggered set in the condition. =]

Post a screenshot of each transition from Attack to Idle, make sure it includes the conditions. Also, make sure the attack animation isn’t set to “loop” (You have to change that in the import settings for the animation)

1 Like


I took the loop off when he did in the video. =)

I’d like to take a closer look. If you can zip up your project and upload it to https://gdev.tv/projectupload. Be sure to remove the Library folder to save space. Tag me as the instructor and make sure there is a link back to this question. I won’t be able to look at it till this evening when I get off work.

Ok perfect! I’ll do this now. =)

It didn’t occur to me to inquire about the transition from Locomotion to Attack…


You’ll need to add attack as the trigger to go from Locomotion to Attack, and uncheck the Has Exit Time.

That worked! Thanks so much! Now I can finally move on to the next portion of the course.

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