Using evaluate curves to control an animation via player speed?

Elvisish 2 years ago updated 2 years ago 2

How do i adjust an animation curve based on a variable? I have a couple of keyframes that i want multiplied by the velocity of my player and I have a gun bob animation that swings left to right, but I'd like the amount to be multiplied by how fast the player moves. Here's how classic Doom looks, the width (and speed) of the bobbing changes depending on the player movement speed: speed.webm

And here's the keyframes I have: keyframes.webm

My main problem is I have no idea what I'm doing with animation curves or how to control them through Bolt. I have no issue with getting the speed variable from the player, it's just the whole curves/evalute/animation method is very difficult for me to understand!

Bolt Version:
Unity Version:
Scripting Backend:
.NET Version (API Compatibility Level):

Hi Elvishish,

How are you playing the animation from Bolt currently? 

From your video this seems like a full Animation object, not just an Animation Curve (the green curve editor thing). 

From the Unity API documentation example, it looks like you can use a For Each loop on the Animation object itself to get "animation states". Then, using Animation State: Speed (you can add that type in your Unit Options Wizard), you could adjust the playback speed.

Thanks for the reply! It’s an animation with a controller, I’ve managed to set the speed of the animation relative to the player speed but I’m starting to control the actual sway amount, so it just bobs slightly left and right at slow speeds and moves a lot further left and right at faster speeds. I assume the key frame x and y transforms need to be adjusted based on the speed. Are animation curves different to this?