Template states for managing transitions

Currently the animator controller exposes "Any State' as a way to quickly define a network of transitions.

A far more flexible solution would be to give each state a 'template state' field, and have that default to 'Any State'

When checking for transitions, the current state would then refer to its template state, which could be 'Any State' or could be a user-defined state with its own set of transitions.

Right now, I'm in the process of replacing a nice neat 25-target 'any state' machine with 625 individual transitions because I need to make a single exception. It's going to take a while.

I'm currently making plans to implement transition libraries for my animation system so I'm interested in your idea, but I don't quite understand the mechanics of what you're suggesting.

If State A points to State B as its "template state", what does that mean? Does A automatically copy all transitions from B to anything else? All transitions from anything else to B? Is B a real state with an actual clip or a fake with the sole purpose of being a template?

It would work exactly like the 'All States' does now: in addition to any transitions explicitly added to state A, it would also check and execute transitions from state B - and if state B had a template it would fall through again until it reached 'All States'

B could be a real state with a clip and other settings (no reason not to that I can think of)

So if A has B as its Template, you can get from A to C via:

  • A transition from A to C.
  • A transition from B to C.
  • A transition from Any State to C.

In that order of priority?

And that would allow D, E, and F to also share the B to C transitions without needing to declare their own copies as well as G and H to not share those transitions if they don't want them.

I don't use Animator Controllers because they're so restrictive in areas like this, and that definitely sounds like it could be useful.

One example I can think of is getting hit. If you get hit, you Flinch. But you don't want to Flinch if you're already Dead. So instead of AnyState->Flinch, make a fake NotDead state with the if (flinchTrigger) -> Flinch transition and have everything else point at NotDead as their template. That raises two potential workflow issues:

  • Each state might want more unrelated templates so they'd probably need a list each rather than only one that needs to chain into others.
  • That's quite a bit of messing around when all you really want to do is disable Dead->Flinch so wouldn't you rather have a way for Dead to just disable that transition somehow?

There are any number of ways you could implement transition inheritance if you are writing your own system. My suggestion was intended for minimal disruption to how animator controllers already work.

Minimal disruption or not, if the idea doesn't effectively solve the intended problem then it's less likely to be implemented. The last thing Animator Controllers need is another half-assed unnecessarily restrictive feature.

So my question stands: wouldn't it be more effective (and simpler) to be able to selectively disable AnyState transitions for certain combinations instead? Your initial post wasn't very specific about what you're actually trying to achieve.

So my question stands: wouldn't it be more effective (and simpler) to be able to selectively disable AnyState transitions for certain combinations instead?

Personally, I don't think so, no. If all you want is a simple way to fully exclude a state from participating in 'any state' transitions, then you could just add a 'None' option to the dropdown of available template states. Job done, plus you get all the additional flexibility of template states in the same amount of UI.