Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at id.unity.com during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.


    Read our full announcement for more information and let us know if you have any questions.

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:
    982
    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:
    982
    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.