Search Unity

Strange transition or state machine behavior

Discussion in 'Animation' started by tcz8, Sep 24, 2019.

  1. tcz8

    tcz8

    Joined:
    Aug 20, 2015
    Posts:
    504
    How it's setup:
    I have two SSM (SubState Machine) that both transition form the "Any State" node on the same layer and a landing animation on another layer.

    One of those SSM is called "Vault" the other "Falling".
    Inside those SSM there is a single state/anim that transition from the entry node to the exit node (Vault animation and Fall animation respectively)

    The transition from "Any State" to the "Vault" SSM is triggered using the trigger parameter "jump"
    The transition from "Any State" to the "Falling" SSM is triggered using using the trigger parameter "fall"

    How it works:
    Once the anim of the "Vault" SSM caused the player to cross beyond the obstacle, my code sets the "fall" trigger which triggers we transition into the "Falling" SSM.

    While falling, at the appropriate moment I play the "Landing" animation from on another layer and at the same time exit the "Falling" SSM thanks to a condition that tells it to transition to exit as soon as landing triggers.

    The problem:
    After exiting the "Falling" SSM mecanim goes back to the "Vault" animation and finishes playing / transitioning to exit. It looks like its "resuming" the vaults anim or it's exit transition were it was left off when we transitionned to the "Falling" SSM.

    Expected behavior:
    When the "fall" trigger is called and we transition fron "Any State" to the "Falling" SSM we should be done with the Vault. Not return to finish playing it (I'm assuming its what its doing)

    Questions:
    1. Why is it going back to the "Vault"?
    2. Additionnally, when transitioning to "Exit" in the "Vault" SSM i see the transition line turn blue twice, does this mean its playing the transition twice?

    Things I know for sure:
    I added a state machine behavior on the "vault" animation to see if It was going through "OnStateEnter" twice but it is not! Plus the "Vault" trigger is long deactivated by the time we get sent back to the "Vault" SSM.

    I checked my code, my transitions and I see no reason for this to happen. I am no trigerring things twice and any param that was used in the begining gets reset properly. I captured the screen and scrunitized every frame and really cant find an explanation.

    I am at a loss here, please help.

    Thank you.
     
    Last edited: Sep 24, 2019
  2. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,570
    The Mecanim Debugging thread might be able to help you track down the issue, but it sounds like you've already investigated pretty thoroughly and I wouldn't really expect anyone else to be able to help much just based on your description.

    It could well be a Unity bug so you should create a minimal reproduction project to report it.

    In the meantime, you might be interested in Animancer (link in my signature) which is much better at simply doing what it's told. Also, Animancer Pro gives you access to its source code so you can properly debug it if you have problems.