How to prevent character from making sharp turns

I’m making a 3D platformer and I used the thirdperson character BP template as a starting point.
But now I want to make that, when the character is running, he is less able to make sharp turns. So, the faster he is running, the slower his input vector should be able to turn.
I’m aware that I can set the rotation rate in the character movement component, but that only affects the character’s rotation per se, not the movement direction. So I made a set up that makes the rotation rate get lower when he is faster and higher when he is walking slower, but that only results in the character running sideways when turning (because his rotation is slow but his actual movement direction changes the same).

It’s like, I need to limit the turn rate of his velocity vector, not only his rotation rate, so he doesn’t slide sideways.
Would appreciate some suggestions, thanks!

2 Likes

Hello! You can tweak values of Braking UPROPs (how quick will your character stop when input is zero), Friction UPROPs (just friction), Max Acceleration UPROPs (how quick character can change movement direction), Max Speed UPROPs (maximum speed that can be gained)

Thanks for the suggestion! I tried that, but it doesn’t work exactly the way I want. If I reduce friction I’ll have the character sliding sideways when attempting a sharp turn, but that’s not what I want. I want him to turn more slowly without sliding, like a train on tracks (the train is always facing the direction of movement, it cant’s slide, but it can’t make a sharp turn either).

I was able to create a setup that worked how I wanted. I’ll post it here in case someone wants to do the same:

What I did:
First thing, instead of using two “add movement input” nodes, one for forward axis input and another for right axis input (as does the default third person character BP by Epic), I use only one movement input node.
To change the direction based on the input I first created an arrow component (named “TargetMovementDirection(Yaw)”) to store the input direction (rotation).
I then break the control rotation in order to get the Yaw and get the forward and right vectors of the resulting rotation, then add the two vectors and get the rotation from the vector, and set it as my arrow rotation (so now my arrow always points in the direction of the current input).

Below is the function I created to set the arrow rotation (it has a branch to check if there is relevant input, if the input is too small the arrow points to same direction as character - this is to avoid the arrow going back to 0,0,0 in world rotation when the input is zero). The function has two input values, they are the two input axis values (forward and right input axis).

So now I have stored my target rotation. With that, I can use “R interp to” node to smooth the rotation of the movement input vector, interpolating the character current yaw to my target rotation yaw. I also use the result to rotate the character itself so it faces the movement direction (I tried checking the “orient to movement” but it messes up this system, so I unchecked it and did it manually).

Notice I also have a var called “Current walking turn rate”. I use this to change the turning speed based on how fast the character is walking/running. The faster he is going, the less able to make sharp turns he is, so this value should be lower the faster he is moving. As shown below, I used a “map range clamped” node to map the velocity ranging from zero to the max walk speed, to the range of zero to one, and then I used a Lerp node to interpolate between my max walking turn rate to my min walking turn rate (both are custom variables I created for this purpose) based on the value from the previous node. I did it this way because the values are “inverted” in a sense: when speed is zero, the turn rate should be at it’s max, and when the speed is at its max, the turn rate should be at its maximum. This is updated on event tick so it’s always up to date.

It worked exactly as I wanted it to: now the character makes smooth turns but without any “drift” or sideways movement. It feels much better to control the character this way, as his rotation is more fluid.

2 Likes