How to define a precise jump height?

Hello,

I’m having troubles understanding how to manage properly the JumpZVelocity variable present in the MovementComponent class. Basically I would like to define precisely a maximum jump height while still having the possibility to handle the jump with some gravity (which means I don’t want to rely on a predefined animation).

The problem is JumpZVelocity seems to not be linear and I don’t see how I could setup a limit to my jump, like 128/256 units in Z maximum. Very low values almost produce no jump while increasing just a bit between 350 and 400 for example makes big differences.

I believe this is somewhat related to the gravity ? How could I setup something precisely without having to try and guess the value I’m looking for ? Also how to adjust it in case the gravity change ?


Note : I’m using a custom DoJump() function, based on the one present in the MovementComponent class. However the application of the JumpZVelocity variable is identical.

If you are using a custom DoJump function what is wrong with scaling the JumpZVelocity accordingly?

The velocity is used within their standard character physics integration and treated as an instantaneous acceleration. They check against jump height in GetMaxJumpHeight using the standard max height formula. You can adjust off that height ahead of time if you want to use that number. Otherwise, the CharcterMovementComponent also has a GravityScale member for adjusting the return value of GravityScaleZ()

Thankts for the GravityScale variable. I missed it. Scaling JumpZVelocity in my function is indeed what I would like to do. The problem is : by which value ? GetMaxJumpHeight() is only used in some specific cases and doesn’t have any effect on a simple jump (unless you have some air control, which is not my case).

So I don’t see how I could determine the behavior of the variable properly.

I’m having trouble understanding your current problem. If you scale jump z velocity linearly based off input or some other scale then the corresponding jumps will also scale linearly. You can adjust the set scale by calling getMaxJumpheight to clamp the scale value or do other adjustments.

It looks like my initial argument is incorrect. I did some new measurement and the the character jump exactly the value that I give in JumpZVelocity (as-is, without any modification). The slow-in/out applied by the gravity confused me I think.

Thanks for your time ! :slight_smile: