Download

How to connect two state machines?

We try to use 2 state machines in the same anim bp. Our setup is:

  1. Basic fullbody locomotion state machine (standing idle, sitting down, sitting idle, stand up, walking) which outputs in cached pose called “LocoCached”. The entry state is “Standing Idle”.
  2. Another state machine for right hand only (empty, reaching, holding, releasing) that uses the “LocoCached” and blends it with various right hand animations and IK setups.
    Basically “empty” state just copies LocoCached to the output and “holding” state blends LocoCached and a holding anim using layered blend per bone node.
    Outputs to final pose.

This approach kinda works, except one problem: when state machine #2 changes its state the machine #1 is restarted. Imagine that someone is sitting with empty hands, so machine #1 is in “sitting” state and machine #2 is in “empty state” (that means it just copies LocoCached to its output). Now if we move machine #2 into holding state the machine #1 will be reset to its entry “idle” state and move to “sitting down” state then “sitting” state, therefore the character will stand up and sit down again.

We kinda solved this problem adding to the machine #1 a dummy entry state and a conduit that leads to standing or sitting state without any blending (blend time set to 0). This is better but still the idle animation is restarted.

Is there some better solution to connect two or more state machines?

Somebody else having the same problem https://answers.unrealengine.com/questions/215497/possible-bug-in-using-two-anim-state-machines.html

Usually a state machine is used for locomotion, legs moving, and the AnimGraph used to introduced slot nodes and branch points as torso blends. The state machine can only, as far as I know, play whats called absolute animation and is why playing one will reset the other. The AnimGraph can play Additive animation, a Montage or blend space, using layered blend per bone. The flow direction then would be.

Locomotion > AnimGraph > Blend per bone > output state.

An example using punching instead of say reaching.

if it helps here is what my current AnimGraph looks like.

I started by doing exactly this for my hand animation. I had an enum variable “HandState”, a BlendByEnum node, a code that managed transitions between HandState values. And that worked. But then I realized that what I’m doing is exactly a state machine. So, I replaced my HandState variable by a state machine and moved some of the code in it’s transitions and some other in its events. It’s doing exactly the same thing, but it resets the Locomotion.

I tried the same thing with two very simple state machines, without any blend or montage, just simple anim sequences, it does exactly the same - resets the first machine. Unless there is some reason that I cannot see right now, I think it’s a bug.