Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

So I am having this problem after putting the code in my project.

When I press and hold the "Jump" button again while in mid-air, I somehow get a sudden downward momentum and bring my player much faster than the up movement.

It also happens when I time the jump to the frame when the player becomes grounded in which case the player jumps at a higher speed than normal.

At first, I thought it was because I was using the old Unity input system. So I changed it to the new input system with the "context.called" thingies just like in the code but I am still having problems. It also happens after limiting max air jumps to zero, setting to no variable jump height and disabling both jump buffers and coyote time.


So yeah, I am at a complete loss on how to fix this for the past few days. Any clue on how to fix this would be greatly appreciated. (Think I need to change something in the new input manager?)

I also hit the issue with the "super" jump, when jumping just before landing.


I think it's happening at the moment when the player is just above the ground -> ground check with raycasts says that the player is grounded, but the player's gravity scale is still upscaled for falling.


At that moment, the jump velocity is calculated based on "falling" gravity scale, but at the next frame the gravity scale is downscaled, because player is moving up now. This means that the players velocity is too high, for the new gravity scale, and the player will jump too high.


The fast and easy fix was to update gravityMultiplier and gravityScale at the top of the FixedUpdate, before DoJump() function is called, so it can operate on correct/newest values. Maybe there's a better solution, but this will work for now.


Idk if this is still relevant to you, just posting in case if anyone else stumbles across this issue. 

Oh my thank you for your explanation and fix!

I tried this and it didn't solve it. It only reduced the likelihood. I now understand why  the superjump happens though:

This dev log doesn't contain the full gravity multiplier check needed to handle jumping properly. Copying just what you see here will make your gravityMultiplier variable set itself to your jump cutoff. This is because it's missing a ground check. There's a lot more stuff missing for this gravityMultiplier. Go check out the calculateGravity function in the scripts you can download here.