How do i calculate the current Movementspeed based on ActorVelocity?

Hi, i want to use an AI with a Animationblendspace that changes Animation based on movementspeed.

How can i tell the current movementspeed of the actor ? I am currently using a getvelocity and divide it by 100 but that still seems to be a bit off. Is there a way to calculate this ?

Hi there,

Is there a specific reason that you use VectorLengthSquared node instead of VectorLength?

The GetVelocity node works fine. In order to get the actual amount of velocity, you should use GetVelocity → VectorLength which gives you a single float value representing the speed of your character in (Unreal_Units / s). Unless you have a specific reason, I suggest you work with the Unreal Engine default units for the length which is in centimeters.

If for any reason, this doesn’t give you the value you want, you can very easily calculate its speed in every frame. Start by creating a float and Vector variable in your character blueprint. Let’s name them CurrentSpeed and PreviousLocation. Next, calculate the speed using Tick Event as in the following:

You can verify that the value of CurrentSpeed is the same as the one returned by GetVelocity node.

Hope this helps.

3 Likes

No there is no reason, i just learned this from a tutorial. Much thanks for your detailed answer, i will try that !