Search Unity

State Machine Behavior variables don't update in the inspector when game is running:

Discussion in 'Animation' started by esco1979, Jan 26, 2017.

  1. esco1979

    esco1979

    Joined:
    Mar 18, 2014
    Posts:
    138
    Like the title says: I click on the object with the animator component, then click on the appropriate state machine under the animator window, so that I can clearly see the script and it's public variables being displayed in the inspector under that particular state machine. But even though the game is running, and the code all works fine as it should, for some reason in the inspector none of the variables update for the behaviours. This happens with ALL of the state machine behaviour scripts I have. This of course makes bug testing a pain. I could always put a copy of the var under a normal script and yes I can even use debug.log and it clearly tells me that yes the variable is updating correctly, but these are unnecessary extra steps. Why is this? Is there some setting that I need to change to get them to update correctly?


    Also, if I use animator.crossfade to change from one state machine to another.... is there some function I can use under OnStateExit to tell me what state machine it is set to go to next?

    P.S. using version 5.4.2f1 of Unity.
     
    Last edited: Jan 26, 2017
  2. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,338
    You need to select the animator that the animatorcontroller is attached to in the hierarchy. Right now you're looking at the animatorcontroller asset, not the one that's in the game and is being updated.
     
  3. esco1979

    esco1979

    Joined:
    Mar 18, 2014
    Posts:
    138
    Huh? That doesn't really make sense. If I select the animator then the script won't still be displayed under the inspector. Instead, the object that the animator is attached to would be displayed. And if I selected just the animatorController itself under assets then nothing is displayed. Am I misunderstanding what you are saying?
     
    Last edited: Jan 26, 2017
  4. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,338
    Kinda. The animator you're seeing in the window is not the animator on your object. It's the animator asset. To show the state of the animator in the scene, you have to select it's object in the hierarchy.

    This is easy to see with say a bool. Add a bool to your animator controller, and duplicate the object in the scene with the animator controller on it. Click one of the objects, and change the bool. Then click the other. You'll see that the bool is set on one of the animator controllers, but not the other.

    It used to be that the inspector for the state machine behaviour was the same. It showed the values for the scripts the selected state on the last selected animator. I did a quick check now, and Unity seems to have broken this for 5.5, it simply shows the value for the asset.

    I'm at least pretty sure that this used to work.

    Anyway, you've found a bug! @Mecanim-Dev, is this a known issue, or should we post a bug report?
     
  5. esco1979

    esco1979

    Joined:
    Mar 18, 2014
    Posts:
    138
    Yeah, I just uploaded to 5.5.1f1 and still busted. That explains why it's not updating. Hopefully they fix this ASAP it's a pretty big thing to not have working.
     
    Last edited: Jan 27, 2017
  6. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,338
    Won't get discovered unless somebody sends a bug report! It's under Help->Bug Report in the editor.
     
  7. esco1979

    esco1979

    Joined:
    Mar 18, 2014
    Posts:
    138
    Ok. I just sent a bug report.
     
    theANMATOR2b likes this.
  8. Mecanim-Dev

    Mecanim-Dev

    Joined:
    Nov 26, 2012
    Posts:
    1,675
    Thanks, we will take a look asap
     
  9. esco1979

    esco1979

    Joined:
    Mar 18, 2014
    Posts:
    138
    Does anyone have any updates on this issue? I haven't heard a word back since I submitted it and I just downloaded the newest version of Unity and it still seems to be broken.
     
  10. Mecanim-Dev

    Mecanim-Dev

    Joined:
    Nov 26, 2012
    Posts:
    1,675
    Hi esco, I'm investigating the bug this week as part of our bug bash week.

    By then end of the week I should have more info
     
    theANMATOR2b likes this.
  11. esco1979

    esco1979

    Joined:
    Mar 18, 2014
    Posts:
    138
    Ok. I'll keep my eyes on this thread. Thanks for the heads up.
     
  12. Mecanim-Dev

    Mecanim-Dev

    Joined:
    Nov 26, 2012
    Posts:
    1,675
    Hi,

    The bug has been fixed this week, it should land in 2017.1 anytime soon.
    We will discuss with the team if we will backport this fix in 5.6 too.
     
  13. esco1979

    esco1979

    Joined:
    Mar 18, 2014
    Posts:
    138
    Thanks for the update. I should also mention something else I just noticed since it is related to behaviour scripts: at the moment any new behaviour scripts created are by default placed into the topmost assets folder automatically. There seems to be no way to choose which folder they are initially placed into after creation (unlike with normal scripts).

    Not a big deal at all. But just letting you know.