Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Question How to avoid settrigger activate the previous animation after finish

Discussion in 'Animation' started by NewMagic-Studio, Jul 4, 2020.

  1. NewMagic-Studio

    NewMagic-Studio

    Joined:
    Feb 25, 2015
    Posts:
    454
    I checked the settrigger docs and it says https://docs.unity3d.com/ScriptReference/Animator.SetTrigger.html
    "A typical example might be to have a Jump option. If this option is entered during run-time the character will jump. At the end of the Jump the previous motion (perhaps a walk or run state) will be returned to."
    I do an attack animation, then use settrigger to go to another animation but i realized that after finishing that animation it attacks again
    Dont know why with other animations in which i use settrigger doesnt happen the same
     
  2. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,582
    A trigger will cause one transition then go back to false. So if you think it's causing more than one you are probably setting it multiple times.
     
  3. MathewHI

    MathewHI

    Joined:
    Mar 29, 2016
    Posts:
    508
    It might go back to false but somehow it "saves" the animation and plays it as soon as the current animation is done. For example I could be in the crouch animation and press punch, kick wait for a long period of time in crouch then release crouch and the punch and kick animations would play long after the input.
     
  4. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,582
    If punch and kick are both triggers then they will remain true until they have caused their associated transitions. They will cause the transition once and then set themselves back to false.
     
    Zimbres likes this.
  5. MathewHI

    MathewHI

    Joined:
    Mar 29, 2016
    Posts:
    508
    I see, I didn’t know it was the transition that turned them false. I’m going to have to re-evaluate my animator controller, thanks
     
  6. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,582
    If you ever get sick of wasting time messing around with Animator Controllers, you should check out Animancer (link in my signature) which lets you control everything directly in scripts.