Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Resolved After animation in an animation layer is done playing the character remains in the last position of

Discussion in 'Animation' started by ZeHgS, Apr 20, 2022.

  1. ZeHgS

    ZeHgS

    Joined:
    Jun 20, 2015
    Posts:
    117
    DESCRIPTION
    I am learning to use Animation Layers. I created one with a mask so only the torso and head are affected. It has an empty state so that the animation isn't played first thing automatically, which transitions to a torso hit animation when a trigger is activated. The animation is set to "Additive" with weight of "1" as I want the the animation to be played with all of its intensity.

    The animation works beautifully and when my character is shot in the torso it seemingly winces from the pain by bending its torso down while continuing to run or do stuff.

    PROBLEM

    After the animation is completed, the character remains with its torso bent down and continues running/doing stuff in that position instead of simply assuming the position of whichever animation is playing in the Base layer.

    WHAT I TRIED

    Fiddling with all of the settings visible in the image below, including "has exit time" and "interruption source", creating a transition back to the empty state and googling. Unfortunately, this is the full extent of my knowledge.

    SETTINGS



    QUESTION

    How can I have the character revert back to the position of whichever animation is playing in the Base layer after the hit animation is played?
     
  2. Flylake

    Flylake

    Joined:
    Feb 26, 2014
    Posts:
    12
    "...when a trigger is activated"

    Some people suggest avoiding triggers because you have to manually release them (they function basically as a regular bool value)

    i suggest the following:

    Remove transition from Empty to Hit State
    Add Transition from Hit to Exit
    in script where you do :
    "Animator.SetTrigger("Whatev...");
    instead do:
    "Animator.Play("[LAYER].[STATE]");

    i.e
    Animator.Play("Base Layer.HitState")

    see if that works out for you
     
  3. ZeHgS

    ZeHgS

    Joined:
    Jun 20, 2015
    Posts:
    117
    Thank you so much for replying!

    Someone else on StackOverflow told me to just create a transition back to empty state with has exit time = true and exit time = 1 and it worked perfectly. Thanks for your help as well!