Anim state graph transition by trigger problem


I’m stuck with an anim state graph problem. I have two entities with anims (MH and FO) both sharing the same state graph. I’m trying to achieve two things basically:

  1. First I’d like to make an idle loop where it runs an MH loop 3 times, then after than 1 FO loop - and repeats that pattern. This is my state graph that supports that, and it seems they can both share it and refer to animations in eachother without actually being able to playback that animation they can still wait the same amount of time. So this seem to work, FO won’t play until three loops of MH has finished.

  1. On top of this I would like the user to able to at any time, via events, activate any on of these two states (either go to FO state, or goto first MH state), and after that carry on in the given sequence just like described above in 1.

My take on this has been to add transitions from ANY state gated by trigger parameters which are set in event code. This seem to work, but ONLY if I set the exit time to 0. This is not ideal for me, because I’d like the current state to finish it’s loop before the transition is activated, because if not the machines in the current loop can freeze in a non-ideal state and even be obsctructing the path for the next state animation (since this is two different anim components here).

Any suggestions on how to reach my goal?

This is the workaround I’ve come up with, since it seems transitions from ANY state just will not fire unless the exit time is 0. Don’t know if this is to regard as a bug or not.

Via code before transitioning I’ve made sure to fast forward to the end of the current state. This in combination with Exit time 0 from the ANY state transitions solves my issue:

        // Set the current state to it's end time. 
        this.mhAnim.baseLayer.activeStateCurrentTime = this.mhAnim.baseLayer.activeStateDuration;
        this.foAnim.baseLayer.activeStateCurrentTime = this.foAnim.baseLayer.activeStateDuration;

I don’t understand this as it’s effectively the same as setting the exit time to 0? Why do you need the animation to be at the end before doing the transition with the trigger?

If I exclude that code, the current step will freeze at whatever progress it’s at. In my case that means some of these vehicles will stop right in the middle of the road essentially blocking the path for the motion planned for the vehicle in the state I’m transitioning to.

If I do that code to fast-forward the current state to it’s end frame before transitioning, that’s not a problem.

Right, it sounds like you have this same problem where the animation that you are transitioning to doesn’t animated the bone that sets the position of the object: Problems with the new animation graph

Animations will only animate bones that have keyframes in the animation.

ah, so the fact that I’m dealing with two separate fbx-files is perhaps part of my problem - where animation A is not aware of any bones or nothing coming from the fbx with animation B. So perhaps If I included both set of vehicles in the same fbx, but with two animation tracks, where B vehicles are keyframed to stand still when A vehicles are moving and vice versa, perhaps this state jumping would take care of things better?

Your current method of fast forwarding is valid.

If you need an animation to be in a particular pose to work, you need to add that pose as the first frame in the animation. It doesn’t matter if its in the same or separate FBX file