Search Unity

Animator sometimes gets stuck in a certain state?

Discussion in 'Animation' started by MosquitoByte, Mar 9, 2020.

  1. MosquitoByte

    MosquitoByte

    Joined:
    Sep 17, 2018
    Posts:
    213
    I have a gameobject which can walk in four directions, and its animator has an integer called FacingDirection which dictates which animation state to play, for example, the default state is DownStop, which plays the downward walking animation at a speed of 0. it will be transitioned to if Facingdirection is 1. DownWalk plays the downward walking animation at a speed of 1, and is transitioned to if Facingdirection is 2, etc.

    the problem is, sometimes the animator gets stuck in either downwalk or downstop, and i dont know why. It doesn't always happen, but i can get it to happen if i try for about 30 seconds. Every state can transition into each other, and the debug log shows that FacingDirection is in fact being changed correctly every frame. So why?
     
  2. MosquitoByte

    MosquitoByte

    Joined:
    Sep 17, 2018
    Posts:
    213
    update: it doesn't seem to happen with any states other than downstop and downwalk, i cant get it to happen with any other state. Also, changing something about the state in the inspector makes it update to what it should be. IE if the state should be changed to UpStop, and is currently stuck in WalkDown, changing something about WalkDown, such as the name, will update it to UpStop like it should be.
     
  3. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,570
    That's not enough information for us to go on. We would need at least a few screenshots of your Animator Controller and transition settings.

    Or you could check out Animancer (link in my signature). In particular, the Directional Sprites examples demonstrate a much easier way to implement directional animations than anything you can do in an Animator Controller. And if you are making a 2D game you probably don't need any of the Pro-only features so you can use Animancer Lite for free.