How can I use a Variable to interpolate linearly (no loops) between animation in Animation Blueprint?

Hi!
I’m building a kart game using Chaos Physics, so far it has been a journey but I’ve been able to overcome most of the issues so far, and keeping a steady pass.
Ok, so far I have a main Blueprint for my Kart that handles the movement and all the inputs from the Player. Inside that BP I have a Skeletal Mesh of the pilot. For him, I have a static pose that acts as my idle pose, and from that I have an animation to steer right and another for steering left. Both steering animations starts from the base pose, and the animations are a combinations of animating bones and using morph targets.
Inside the Kart BP, I already have a variable for the steering angle that is updating each tick, getting it directly from the front wheels of the Kart instead of grabbing it from the Controller Input, as in some conditions there is some automatic countersteering.
Now I’m building the Animation Blueprint for my pilot: in the Event Graph, at Event Blueprint Initialize Animation, I’m doing a cast on my Kart BP and promoting it to a variable, so at Update Animation I can use it to fetch the steering angle from the Kart BP and setting it as a variable. (I think this is the most clean solution, I’ve also tried fiddling with BP interfaces in order to pass this variable, maybe that would be better for reasons yet unknown to me?)
Now the question is this: I’d like to be able to use this steering angle variable to control the interpolation between these 2 animations, so that at zero steering value my pilot stays in idle position, with max steering in either direction we reach the last keyframe of the animation and hold it, and any value in between gets mapped to the interpolation of the animation, so that it can go back and forth in the timeline animation depending from the steering angle.
I’ve already set the Idle position into a state machine and I was trying to implement the steering, but I can’t find some resources to help me do it, all I can find are topics about Blend Spaces, but I think those are for blending between looping animations?

Anyway, I hope I made myself clear, thank you in advance for taking your time on this!

This seem more like a job for a blendspace. You can add in directional animations and unreal will do the blending for you. You just have to set the variables for the axis and then you can drive the blend from within the animation blueprint.

1 Like

I’ve tried with blendspace, maybe I wasn’t able to make it work properly, but I have two animations for steering, as I have some cloth with some animating morph targets to compensate for the steering animation, so I don’t have static left/right poses to blend, and if I try to blend the two animations, they’ll cycle loop.
I have a range for the steering that goes from 0 to 22.5 for each side, and the animation for the steering spans across 30 frames. My goal is to map the range of the steering to the range of the animation. How would I go to do it with blendspaces? All examples I can find show looping walk cycles, the video you posted is very useful to blend different locomotion inputs, but again it works with looping cycles, I’m not sure how to make it work in my case…

If you select the animation sequence in your blueprint you can right click “Convert to Single Frame Animation” and then input the math to swing the animation left and right using the yaw.

1 Like

Yes I’m working on a solution like the one you’re proposing, so far I’ve made a state machine with the base idle pose, and two transition rules to transit to each animation depending on the steering angle, for each state (left or right steering) I’ve mapped the steering values to the explicit time, and to go back to idle when the steering value goes back to 0. It seems to be working like this, but if I toggle too quickly between left and right, the animation gets stuck between one of the turn and the idle pose, I guess it has to do something with the Transition Rules? Right now I’m updating the steering angle value from a custom tick (a set timer by event that loops every 0.01 seconds), and my transition rules are something like this: if steering angle is <0, transition to Left Turn, when steering angle goes back to ==0 then transition back to idle pose, and same thing with Right Turn for values >0. So I guess something is not working properly when going too fast from negative values to 0 to positive values. Is the state machine even the best way? I’ve tried branching in the Animation Blueprint, but for the love of me I can’t seem to be able to understand how does the execution line works for the Animation Blueprint…

Ok I’ve managed to make the blendspace not looping, and it’s actually interpolating better between the animation for values changing fast around the 0, meaning where pose and the two animations should blend. Animation breaks though: I have a cloth that is being animated using morph targets, and I can see the mesh (that is driven by joints) poking out of the clothes pretty much at any steer value. I guess it is because it keeps blending between the different poses and animations at any given value, instead of using the steering value as an absolute parameter to interpolate between animation timelines and poses.
I’ve tried the other way also, doing it straight into the Animation Blueprint, I’ve converted the different animation sequences into Sequence Evaluators, exposing the Explicit Time, and with A Map Range Clamped I’m mapping the steering values into the correct animation frame, and it doesn’t brake, both the joint animation and the morph targets are right at their place, no mesh poking out or misbehaving. I’m switching between these animations using a state machine with different states, and sometimes it doesn’t seems to be able to switch to the correct state, especially if values are going up and down fast around zero without ever stopping at perfect zero.
The perfect solution would be either to use blendspace and tell it to use the absolute keyframe of the corresponding animation on value instead of trying to blend between all of them depending on the value, or to do it in the Animation Blueprint, put the 2 animations + 1 pose in a kind of a mix node or a blend node, and use the steering angle as an alpha between the three of them

Ok, so I made a couple of screenshots and videos, to better show my current situation.

So these 2 are the Animations for steering left and right. The character mesh in being animated by bones, while the clothes are a Marvelous Designer sim converted into Morph Targets. The animations, in their whole, work without breaking.
Now, for the Kart/Scooter, there’s a whole other Blueprint that uses Chaos Physics as vehicle, on which I have already a Steering Angle variable that is being normalized, with values that go from -65 (max left steering) to 65 (max right steering). So in the Anim Blueprint Event Graph for the Pilot/Granny, I did this in order to grab the Steering Angle variable:

Once I’ve grabbed my steering variable that updates on each tick (I guess that’s what Event Blueprint Update Animation stands for?), I tried implementing the animations through state machines:

So pretty much this is my state machine: I have a static pose as idle (is the first frame in both animations, so blending is kinda already there) and tranitions to and from the different animations.

This is the transition rule from Idle to Left Turn. The logic for the Right Turn is the same but for steering angle values>0. Both Left and Right transition back to Idle on Steering Angle==0.

So for both Left and Right steering state, I’ve managed to map the steering angle into the correct values for the animation Explicit Time slider (for right steering is the same but ranges from 0 to 65).

This is the result at runtime:

So this is what happens using state machines. It does work, until the steering angle changes too quickly between positive and negative values, then the transition logic breaks.

The issue is quickly solved with the use of blendspaces, that ensure a clean transition, even for quickly changing values. But then I run into this issue:

I guess it’s happening because clothes, being driven by morph targets, are blending and morphing with the other poses/frames in other animation, therefore the interpolation of morphs is incorrect at some given values in time.

I know probably the ideal solution would be to simply skin the clothes to the skeleton, or to go for a cloth sim, but weight painting is giving sub-optimal results so far, and the cloth sim is too heavy and not necessary, considering chaos physics for the vehicle is already running, while baking cloth sim into morphs seems to give me the right balance between being visually correct and cheap on memory.
Any ideas on how to optimize either the blendspace for the morph target, or to implement a smoother logic transition between the different states?
Thank you so much in advance for taking your time, I hope I’ve made my situation a bit more clear.

Why not just bind the clothes to the underlying skeleton and if you need any simulation then only add it to the bottom of the jacket. The sleeves can easily be purely skinned. If you want some wind motion you could try adding some noise to the wpo of the coat.

1 Like

Yes I tried that, skinning the clothes in the best possible way and then simulating cloth only for a small part, but even adding the slightest cloth sim over chaos vehicles seems to take a big toll on fps, maybe is just that I don’t know how to better optimize it.
In any case, I’m going for a bit of stylized look on some animations, I’ve already have some jump animations and I’ve tried both methods and no matter how much I spend on clean weight paint when I confront the two results it’s awful, plus looks like morphs are way cheaper than even the smallest cloth sim…

Other than that yes, my goal is if I manage to make this work, I’ll add a small noise to the wpo of the clothes just to sell the wind a bit better, it was actually my next step but I’ve been stuck into this for some days now

I’m wondering, would VAT be a smart solution? Or am I already too deep into this rabbit hole?

VAT is overkill in this situation. It’s a more cumbersome system to control and is used mostly in conjunction with HISM’s / ISM

1 Like

Ok thank you I think I’m already loosing my sanity enough

GOT IT!!
I knew it could be something simple! So this it’s my current solution:

I’ve made only one state change, to avoid transition state error at quick changing values. Now it goes from Idle to Steering for any values !=0, and goes back to Idle at any 0 value.
Then, inside the steering state, I’ve used a Blend pose by bool:

And that’s it! Now the Blend by bool is outputting the correct blend at any correct value, even when changing quickly from positive to negative, as soon as it stops steering, it simply goes back to Idle.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.