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.
  2. Dismiss Notice

Question Return to "Idle" Animator Issue

Discussion in 'Animation' started by BlackSabin, Mar 27, 2023.

  1. BlackSabin

    BlackSabin

    Joined:
    Feb 27, 2021
    Posts:
    73
    So I'm messing with my animations I've encountered the following issue: Swing.gif
    ... the swing animation doesn't exactly, uh, return to "rest". I don't even know where to begin designing such a mechanic, as the animator is mostly new territory for me. I followed a set of tutorials in the past to get my current working knowledge and have set up the animator with two layers as such; the base layer handling movement, and the Override layer handling any character actions required. The Override layer is set to a weight of 1 so that if an animation is set to play by script, it takes over completely. How might I incorporate a way for the animation once finished to smoothly return to what the base layer is doing?

    BaseLayer.png
    OverrideLayer.PNG
     
  2. Unrighteouss

    Unrighteouss

    Joined:
    Apr 24, 2018
    Posts:
    599
    I would definitely not control the character's movement in the animator and instead control it through code. This way, you'll only have a single layer and it'll completely eliminate the issue.

    If you're set on doing things this way, the only solution I can see is to smoothly adjust the weight of the override layer in code to create a smooth transition out of it.
     
    Homicide likes this.
  3. Homicide

    Homicide

    Joined:
    Oct 11, 2012
    Posts:
    637
    But, if you are intent on following through with your implementation, set the layer weight to 0 after the animation is complete.

    You could do this with an animation trigger when the attack is complete, that your script listens for and sets the weight to 0.
     
  4. BlackSabin

    BlackSabin

    Joined:
    Feb 27, 2021
    Posts:
    73
    To clear up a few things: firstly, the character's actual movement itself is not controlled by the animator. I have a parameter that one of my scripts passes the character's movement's magnitude, and the "Locomotion" animation is a blend tree that goes between "Idle", "Walking, and "Running" based on that magnitude. The actual movement is in fact controlled by a separate script entirely.

    Secondly, the shown animation "Swing1" ends with the character's "hands" outstretch with the blade: I eventually plan on implementing a type of weapon combo system so that for example after "Swing1" ends and the player hits a button, "Swing2" will play instead of returning to rest. To that end, I need to find a way to have any of the animations return to a resting position.

    I'm starting to think that maybe a solution to this is to have a separate "Swing1Return" animation play automatically before coming back to "Empty". I tried moving all the animations to the same layer and the animations ended up getting cut off before playing in their entirety, and moving the end times/transition offset only made the animation end too early or weirdly repeat itself.

    While I could create a script that would transition the weights of the layers from 1 -> 0, I'm pretty sure it would end with the same results as merging the layers as previously mentioned: animations would overlap and not look right.
     
  5. BlackSabin

    BlackSabin

    Joined:
    Feb 27, 2021
    Posts:
    73
    upload_2023-3-27_18-7-35.png
    That fixed the issue splendidly; I will thank you for your suggestions though. You both seemed worried (maybe I'm reading into it?) about me continuing this kind of implementation though. What concerns or potential limitations should I be wary of moving forward with this?