Hello everybody I am trying to make a multiplayer game where pawns can access the same movements that Battlefield’s pawns have:
I started with a third person project, imported my skeleton mesh and my animations.
Created an animation blueprint and created lots of blueprints in playercontroller class, added sprint, crouch, modified base stats for walkspeed, air accel, ecc…
Then I created a 2D blendspace.
Since my character can go from -180 (when moving backwards) to 0 (idle), to 450 (running) to 900 (sprinting) and his lateral speed can go from -400 to 400 I created the blendspace with X between -400 and 400 and Y between -180 and 900.
Now, one of the problems I had was to feed local speed along the X and Y axes because “Get velocity” gets the absolute velocity but the X and Y speeds are based on world XY axes so if I move forward in a direction I get a certain speed, but as I change my angle by rotating the pawn the X speed is different.
So this was not the correct approach for feeding x and Y speed to the blendspace.
My idea then was to get the transform of the pawn and the velocity and inverse transform them to get the “Local Forward” and “Local Lateral” speed out of an event tick.
Perfect! Worked like a charm and regardless of the world orientation of my pawn, I was now feeding basically the speed relative to the X and Y axes of the pawn itself rather than the speed relative to world coordinates.
So far so good, I fed those values to the blendspace and it worked!
Problem is tho, that character rotation changes those values a lot!
Let’s say that I’m walking laterally and meanwhile rotating, the variation on the axes is huge. And since it is calculated per frame what I now feed to the blendspace are not anymore local speeds (I mean, they kind of are…) but those speeds are now tangent speeds. The result is, since it is bound to the frame, that turning the mouse or rotating fast causes jittering.
This is what happens in game: