Get Characters current walking speed

I have a player character derived from ACharacter and I have a function which is called every time the jump button is pressed. Now whenever that happens I want to get the velocity with which the player is moving forward (kinda its current local velocity along the X axis). So basically the walking speed at the time you jump is hoing to be stored in a float variable. I need that for wall running.

I would get the velocity FVector of the root component and dot product it with an X-axis: FVector(1.f,0.f,0.f).

If I remember correctly, you can also access velocity via the CharacterMovementComponent.

It would look something like this:

FVector A = Velocity;
FVector B = FVector(1.f,0.f,0.f);
        
float WalkVel_X = FVector::DotProduct(A, B);

It doesn’t seem to work. I’m getting completely “random” numbers. I’m thinking of doing something like in this: How to get local velocity? - Blueprint - Epic Developer Community Forums
Though I ran out of ideas how to get the forward vector of actor rotation. Also, what does the DotProduct actually do?

Got it:

wallSpeed = FVector::DotProduct(GetVelocity(), GetActorRotation().Vector());

Thanks for the help.

Glad you got it solved. Make sure to ‘accept’ your answer so that the thread becomes listed as ‘resolved’.

Is there a way to account for the side moments? I see that is method only works for forward and backward movements.