Lean direction interpolation


Disclaimer : This was done using UE5 Early access, but the logic is exactly the same if you were to do it in 4.26 or lower.

Alright so I have a leaning function created inside the basic pawn character blueprint. Pressing E leans right and pressing Q leans left, and this works very well and I am happy with it.

One thing I can’t quite figure out is how I would go about creating some sort of interpolation between both of the lean directions if say you were to activate leaning left just after leaning right and vice versa. Currently when you try and do this, it jitters and looks very sudden, whereas I would like it if it were to be either smoothed or maybe not allow leaning in the opposite direction unless the relative transform is returned to default?

Is it possible for anyone to shed some light and give me some insight on how I would go about doing this?


EDIT : Also to clarify why each timeline has an event ramp that is being out put into the opposite timeline set new time, it’s just a temporary fix I found which makes it not look as janky and jittery.

This took me way longer than it should have, sorry if my original answer misled you.

Using timelines and lerps for this sort of thing can be limiting, instead try to recreate this.

if the player is not pressing any buttons then move the lean amount to 0.
If the player is holding left or right make a number go up or down.
If the player is holding two left and right at the same time then don’t do anything.
Plug LeanAmount into your rotation.

If this works for you then please mark my answer as correct by clicking the little tick icon beside the two arrows to the left.

Hello! So I recreated the sequence you showed above. My current lean mechanic was using relative transform for the camera, and had nothing to do with rotation because I was using the default pawn character setup that also controls rotation tied to the pawn itself. Is it possible to have this control the transform of the camera to the left and to the right, and also what should the outputs leaving set lean amount look like?

I couldn’t figure out a hybrid of the horizontal default pawn mouse rotation, with a custom vertical rotation system, therefore thats why im currently only using the default.

"Is it possible to have this control the transform of the camera to the left and to the right", drag off of the transform node and type Make Transform, drag off of the rotation pin from make transform, and type Make Rotation, plug the Lean Amount into one of the floats in the rotation depending on which one you are using, I imagine it will be the X.

"What should the outputs leaving set lean amount look like?", get a Pring String node and plug Lean Amount into the text. If you are looking for what my values were. Lean Speed 3’ish, Max Lean try 45.

"I couldn’t figure out a hybrid of the horizontal default pawn mouse rotation, with a custom vertical rotation system, therefore that’s why I’m currently only using the default." I don’t know what that means. Horizontal default mouse rotation? Using the default? Is your character is moving into the ground/flying into the air when you lean and move at the same time?

If you are still having trouble and need some help, send me an image of what you are having problems with. Right now it sounds like you just need to make or break some vectors somewhere, or possibly parent the camera to a scene component so that you rotate the scene component on the Z and rotate the camera on the X with the lean amount.

Sorry, was away from the house for a day. I’m using the default pawn rotation for the camera etc. I was referring to unlocking the default pawn rotation set to the camera to allow external rotation on the camera(Leaning) but I would need to come up with my own vertical rotation for the camera, and for some reason I ran into problems where clamping the rotation would infact limit the rotation up and down, but there was a way to still over rotate the camera by moving it around really fast.

Also, I’ve gotten your leaning method to work for camera rotation. It works exactly as I need it to, I really appreciate you helping me!

Now another hurdle I have is to try and either transform the camera to the side along with the camera rotation, or rotate the capsule slightly along with the camera.

Yeah thats exactly what I wanted actually, But for some reason this function now only allows vertical rotation of the camera and locks horizontal rotation of the capsule component


And also, one last thing, the leaning locks the ability to rotate the camera vertically, and also snaps to the zero position if looking down and up when initiating lean.

EDIT AGAIN: I actually just solved that. WOW this was a doozy, I really appreciate you helping me, you are a real one!!

Is this what you want? Look at how I give the camera an extra scene to rotate on.

Ah, there is 1 more problem in my code, world rotation is used for left and right camera input.