Find the Relative Left and Right Speed of a character?
So basically what I'm trying to get is the left and right speed of my character relative to himself.
Meaning, when I walk forward I walk at lets just say positive 80mph. If I walk backwards it would be -80mph. That -80mph to 80mph would be the forward backward speed.
As for left and right, lets just say right is positive 80mph and left is - 80mph. That would be my leftright speed.
No matter what direction you're facing, that would stay the same. You'd always have a left right and forward back speed
The problem is I can't figure out a way to find said left and right speed, and to an extent a proper forward backward speed. That being because of the way most online resources tell you to get your speed, which is through the players velocity. But when you get a players speed through their velocity, no matter what direction you're moving, it's always going to be the same (Depending on the speed you're travelling) For example, in my game the walk speed is 300. when I move forward, back, left or right, the velocity will output 300 no matter what. For my system I need two separate speed variables, as mentioned above
So Is there anyway to find my velocity, or just general speed relative to my character? The main reason for this question, is that I want to setup a proper blend space, in which I have strafing animations that go to the left and right. And of course I want them to blend smoothly, and make their own little strafe left forward and strafe right backwards etc animations.
I hope I explained this well, I'm bad at explaining things.
I also drew a mockup picture of the general idea here.
The triangle is the player, with the point facing where the player is facing.
The F B L R is forward back left and right respectively
The dots represent test points, and the giant red circle is implying the direction does not matter, or that this model with stay connected to player.
I'm sure there is probably a more accurate and better way (my vector maths is terrible), but here is something that kind of works. It gets the left/right speed if you're strafing.. Problem is that it also gets a bit of speed if you turn left and right.
Hope this will at least guide you onto the right track :)
answered Mar 08 '15 at 08:36 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here