Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only. 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 Animator Randomly Goes Back to Default State

Discussion in 'Animation' started by Safemilk, Apr 17, 2022.

  1. Safemilk

    Safemilk

    Joined:
    Dec 14, 2013
    Posts:
    42
    Using Unity 2021.2.19f1 but this happened in many older versions.

    Randomly, during play, both in the editor and the build, the Animator Controller will go back to it's default state. No transitions are triggered, no parameters are telling it to do this, in fact all the parameters remain correct and show the state the animator SHOULD be in.

    In my case, this means when triggering various state changes in the animator, for example, holding right click to go into ADS with my weapon, the animator will jump to default state, which is holstered, however the holstered bool remains false.

    This seems to happen at lower framerates, or if there is a hitch during gameplay.
    I can see it actually go to the entry node and transition to my default animation clip, but nothing has told it to do this, it seems very random.

    Has anyone else ran into this?

    upload_2022-4-17_9-13-3.png
    upload_2022-4-17_9-13-44.png
     
  2. Flylake

    Flylake

    Joined:
    Feb 26, 2014
    Posts:
    12
    I read somewhere for an unrelated topic that if the animator reaches a dead-end (i.e animator reaches a state, finishes playing but has nowhere else to go afterwards) that it might default to the Exit Node (although I think this was in a sub-state machine)

    Have you ever experienced the 'reset' during a looping animation?
     
  3. Safemilk

    Safemilk

    Joined:
    Dec 14, 2013
    Posts:
    42
    Hey! Thanks for the reply, sorry I didn't get back sooner!

    I don't think I've seen this happen during a looping animation, it only seems to happen when I'm rapidly going in and out of ADS while moving.

    I wonder if that combination of states is actually dead ending it in some way? It doesn't feel like an exit node triggering, but maybe it is!

    I'll see if I can isolate that/eliminate it, if that's it then it would be great, then I could fix it on my end! If I figure out what it is, I'll definitely post a follow up here.
     
  4. Safemilk

    Safemilk

    Joined:
    Dec 14, 2013
    Posts:
    42
    Bringing this back up again, still having this issue in 2022.1.13f1!

    Code (CSharp):
    1. if (Input.GetKey(KeyCode.Mouse1))
    2.             {
    3.                 characterBasic.myAnimator.SetBool("ADS", true);
    4.                 characterBasic.ads = true;
    5.                 characterBasic.isSprinting = false;
    6.             }
    7.             else
    8.             {
    9.                 characterBasic.myAnimator.SetBool("ADS", false);
    10.                 characterBasic.ads = false;
    11.             }
    This is pretty much all that I'm calling to set these things, they are looping anims, and during low frame rate moments, (sometimes even high framerate moments) the whole animator just gets rid of it's place and goes back to it's entry state.

    It happens exclusively when I'm rapidly entering and exiting ADS, sometimes just on the first attempt to aim down sights, sometimes after a while.

    Feels like maybe there's some other thing interfering with the animator I don't know about.

    Has anyone else ran into this issue?
     
  5. Safemilk

    Safemilk

    Joined:
    Dec 14, 2013
    Posts:
    42
    @Flylake ! You were right all along! I found my substate had exits just fine, but after it got out of the substate, one of those exits got dead ended by exterior transition requirements!

    Annoying that it took me so long to find, but grateful for your feedback, after I came back here to fuss about it, I read your post again and said, "Let's take one more look!" Thanks again.