Disable direction change when jumping

Hello there,

Is there a way to disable left/right movement when jumping (platform behaviour), so it obeys the laws of physics a little better?

Many thanks,

Old Noob

whatever you are using to move side to side, just make it force off whenever you are jumping or in that air.

I would make a boolean variable called something like “isJumping” and make left/right movement only work when “isJumping” is false.

Then whenever you jump, change “isJumping” to True for the length of the jump animation.

I don’t think the OP is using animations for jumping though. I assume they has something dynamically physics based so they should send a raycast down to check if they are on the ground, and if not, disable left and right movement forces.

In my understanding, they just want to do something like “If you jump running towards X direction, you can’t turn to another direction in mid-air, because you can’t do it in real life.” Which can be achieved by storing the direction in a text variable once jumping, then using that as condition to block the direction change.