Lock Direction of Player when jumping?

Hello, I’m pretty new to UE4 and I’ve been following a few tutorials and such. The problem I’m having is how to lock the player’s rotation to the same rotation as when they jumped? This seems really easy to do but I can’t figure it out. To explain what I mean in more detail: in any platformer, when the character jumps, their rotation is locked to where it was at the start of their jump.

78188-mariojumpback.png

I’ll use the classic Super Mario Bros as an example. In this image, I started facing right. Then I jumped and held the Left Arrow Key and my movements followed the yellow arrow. However, Mario stayed looking the direction I was facing when I started jumping.

78189-mariojumpreverse.png

The same thing also happens in reverse. Here, I jumped and held the Right Arrow Key while facing left (again my movement followed the yellow arrow), and as you can see Mario stayed looking left even though I have moved backwards.

For some reason I cannot figure out how to do this. One thing I tried was to store current Rotation in a variable and then set the variable On Jump Event. I thought this would set the variable once and then I could lock him in that Rotation. Instead, it constantly updated the variable, so it was constantly setting the Rotation to itself, and basically it had the same effect as if I didn’t have the blueprint in the first place. Can anyone help me with this? I would appreciate it very much!

HI,

A quick way I would do this, is off your left and right, let us say arrows, put a bool in, “Is jumping”,

When jump triggered, Bool = Yes

If “Is jumping = Yes”, check if left and right are hit, and jump in that direction, → Play jumping section. At end of jump section, set bool to No.

If “Is jumping = No”, then left and right “Arrows” work as normal"

Hope it helps,