Precise jump in units?

Hi, I’m trying to find out how I can make precise jumps (in units) with a character.

A character’s CharacterMovement component has a Jump Z Velocity default at 420. Under Project settings -> Gravity Z is default -980.

How does these numbers work? How could I make the character jump e.g: 100 units up in the air via CharacterMovement component (or a blueprint script)?

If you want to change jumping use the function change jump z velocity. If you want the velocity to be a particular number create a float and set the jump z to that float. Than make a way to set the velocity to whatever particular number you.

The specific numbers work as such:

Jump Z is the initial speed, in UU/S, of the character.

Acceleration due to gravity is measured in UU/S^2, which is a change in velocity.

A handy equation from projectile physics for determining an object’s position/ velocity along an accelerating trajectory helps here:

Vf^2 - Vi^2 = 2as

Where Vf is the velocity of the object at the measured point in time, Vi is the launch speed, a is acceleration due to gravity, and s is the displacement of the object.

You want to move the character s units into the air when his velocity is 0 (no vertical speed, the apex of the jump), so you solve for Vi:

Vi = sqrt(-1960*s)

Plug your desired jump height into “s” and solve for the Jump Z velocity.

1 Like

Hello again.

RhythmScript, I tried your calculation but it doesn’t seem to work.

I created new project from third person template and added a BSP box with 200x200x200 dimensions. Project’s default gravity is -980.

So the velocity settings to be able to jump up on the 200x box should then be: sqrt(-1960*200) = 626.099034 i units. The blueprint character ThirdPersonCharacter Jump Z velocity has a value of 600.

But the character still able to jump up on the 200x units box when it shouldn’t be able to. Am I missing something?

The math is definitely correct… Set the player’s collision capsule to be visible, what do you see? Is he just BARELY clearing the box?

Also, are you sure the BSP box is placed correctly? BSP dimensions scale uniformly in all directions, so if you placed the box at floor level and adjusted the height’s size, it would extend down into the floor as well as up toward the sky (and your 200 unit box might only be 150 units off the ground, for instance, with the rest clipped through the floor)

I created an album showing the character and his capsule: http://imgur.com/a/fhSI5#0

You can see his jump height (600) in the second image, clearly he shouldn’t be able to jump up on it. I think the collision of the capsule make him able to do it anyway.

1-2 weeks ago I tried making a character with custom collision instead of using the capsule, but I couldn’t get it to work as I wanted.
Anyway, in this case what I’d want would probably just be a box around the character instead of using the capsule. That’ll fix the problem with the character being able to jump up on the 200x box.

Aha! I see the problem.

Inside your CharacterMovementComponent, change the value of PerchRadiusThreshhold to be larger.

By default, UE registers any contact with the bottom hemisphere of the collision capsule as standing; you want to change this so the player can only stand if the very bottom of his capsule makes contact with a surface.

This was the source of the math issue; technically, the capsule WASN’T clearing the box, it’s just that UE doesn’t require the capsule to fully clear the box to walk onto it

Ahh, I got it to work now. It ain’t perfect but it works. :slight_smile:

Many thanks RhythmScript!