Search Unity

Don't Transition to Self for Substates?

Discussion in 'Animation' started by jaybennett, Dec 22, 2016.

  1. jaybennett

    jaybennett

    Joined:
    Jul 10, 2012
    Posts:
    165
    My top level animator controller looks like this:


    The transitions from Any State to each Sub-state Machine are NOT to a state within the substate. I selected to transition to the Sub-state machine itself.

    When doing this I noticed that when making a transition from Any State to a Sub-state Machine does not show an option to restrict "Transition to Self". Why is this @Mecanim-Dev ?

    The result is that my Sub-state Machine is constantly re-entering itself:



    This flashes from the Any State to Entry node many times per second and leaves my animator completely locked up.

    I don't want to transition to a specific state within the Sub-state machine such as the Idle state (which gives back the "Transition to Self" option). For my requirements, its valid to transition from any action in one stance to any action in another.

    For example, a Sword Moving animation may validly transition into Rifle Attack. Putting the Idle state as a Sub-state Machine default makes sense for some use cases but since my Idle animations vary for each weapon type, it can look very clunky. In my testing with that setup there is a 1 frame Rifle Idle blended into the transition which looks very bad.

    The other option of making a transition for every sub state in the Sub-state Machine is pretty bad too, since it kind of defeats the point of the Sub-state machine. Might as well put everything into the top level at that point.

    Using Unity 5.3.2f1
     
    Last edited: Dec 23, 2016
  2. jaybennett

    jaybennett

    Joined:
    Jul 10, 2012
    Posts:
    165
    @Mecanim-Dev so I ended up doing transitions to every state within the substate and got a really smooth and working result.

    but I wonder how does the animator controller performance scale with transition #? does anyone have info on that?

    Having to transition everything to everything is O(n^2) or maybe O(n) if you just use Any State into every single animation.

    Going from Any State to every animation basically reduces down to the legacy clip playing system with slightly different scripting. I'm wondering if this is a sustainable / scalable approach?
     
    Last edited: Dec 23, 2016
  3. Bravo_cr

    Bravo_cr

    Joined:
    Jul 19, 2012
    Posts:
    148
    Same question here. Any updates?
     
  4. CaseyLee

    CaseyLee

    Joined:
    Jan 17, 2013
    Posts:
    41
    "When doing this I noticed that when making a transition from Any State to a Sub-state Machine does not show an option to restrict "Transition to Self".

    The sub-StateMachines are never really "transitioned" to, they are basically folders contracting actual states so their is no way a Sub-State-machine could transition to itself - rather your state is constantly getting called to enter "some state" in X sub-state machine it doesn't know its is its own.... Anyway hope this clears something up so you can find the logic error in your state machine.




    "so I ended up doing transitions to every state within the substate and got a really smooth and working result. but I wonder how does the animator controller performance scale with transition #? does anyone have info on that?"
    I can tell you my current project I am building the controller proceduraly, and each sub-state machine has 3 transitions from "anystate" - each different transition varies in duration so I can decide in code to change how it looks... anyway ... It ends up being +800 states 100ish sub-state-machines and like ~1500 total transitions - haven't noticed any in-game performance issues, just much increased build and editing time.
     
  5. immeasurability

    immeasurability

    Joined:
    Apr 22, 2014
    Posts:
    125
    as always, unity developers just care about having this feature as Transition to Self for sub Sub-state Machine
     
  6. yonixw

    yonixw

    Joined:
    Dec 25, 2012
    Posts:
    2
    My solution is every transition will have (1) trigger OR (2) a condition with a "triggerAny" trigger that you need to set every time from the code if a change in parameters might affect "AnyState" conditions. That way the AnyState will only activates on triggers. (No other transition allowed to use "triggerAny" in their conditions)