Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Question What is a good way to stop a looping animation when moving?

Discussion in 'Animation' started by mrCharli3, Apr 26, 2023.

  1. mrCharli3

    mrCharli3

    Joined:
    Mar 22, 2017
    Posts:
    961
    I have a looping attack animation, is there an easy way to stop this animation when my character starts moving? Atm I have to always call my "stop" trigger and it doesnt always work great and feels messy.

    upload_2023-4-26_12-17-58.png
     
    Last edited: Apr 26, 2023
  2. ElXill

    ElXill

    Joined:
    Jun 2, 2017
    Posts:
    43
    This feels like more about your aproach to character controller script.

    You can change stop with movement bool and check for when your your character should move. It is not really any different but at least movement would be more meaningful and general use term for state machine.
    Or if your speed increases before movement animation you may use that for a condition for changing to locomotion from attack but i imagine that would be bad for overall quality.
     
  3. mrCharli3

    mrCharli3

    Joined:
    Mar 22, 2017
    Posts:
    961
    Ill try a bool, thanks! So basically a "IsMoving" Bool in the Animator that will exit any node when set to true?
     
  4. ElXill

    ElXill

    Joined:
    Jun 2, 2017
    Posts:
    43
    Yeah, if you want state machine to work that way, though I don't get why prior doesn't always work. It may be something about your transitions settings.