Hello everyone, I am working on a player sprint system for a game, and the player should only be able to sprint if their velocity is already above a certain point. The problem is that the players velocity returns a vector, I need 1 single float (for x & y). So would the Pythagorean theorem (A = Abs(X), and B = Abs(Y) = VelocityFloat) be the best route to check the players XY Velocity?
try using Velocity length
The default blue dude in the 3rd person template has an example of that in the animation blueprint event graph. Also if you want to ignore velocity on the Z axis, you can just break the vector and use just the XY like this.
Ok, so if my max walk speed is 500, won’t this float value go above that due to diagonal movement being a “shortcut” because of both X&Y movement?
Nope, the max walk speed caps out your regular movement control maximum speed in any direction, as long as it’s just your movement giving it the speed. Even if you were walking down a ramp and it also used the Z axis, your overall speed wouldn’t go above max walk speed. If you were falling however, it would be the gravity giving player extra momentum and then it would go past that.
Ok thanks everyone, it works like a charm.