How does jump work in code?

Hey! I was just wondering how I can edit the default jump script or just learn how to make my own. This line is included in the default controller script (first person):

InputComponent->BindAction("Jump", IE_Pressed, this, &ACharacter::Jump);

But the Jump function is nowhere to be found. Anyone know what I can do?

its in Character class. ACharacter::Jump()

“Jump” is just a name of action bound to (most likely) spacebar, ACharacter::Jump() is the actual function that is called when spacebar is pressed (IE_Pressed)

Oh so its built in is what your saying. But say I wanted to change something in the jump (the height, force of the jump, etc.), then how would I do this if it is all predefined? I am guessing that not all UE4 games use the exact same jump…

If you go track default Jump function calls you would find:

bool UCharacterMovementComponent::DoJump()
	if ( CharacterOwner )
		// Don't jump if we can't move up/down.
		if (FMath::Abs(PlaneConstraintNormal.Z) != 1.f)
			Velocity.Z = JumpZVelocity;
			return true;
	return false;

So as you can see Jump command is routed from PlayerController, through Character to CharacterMovementComponent that does the actual jump (adds velocity and sets MovementMode). If you want to create your own jump I would suggest to create your own CharacterMovementComponent that derives from UCharacterMovementComponent and overrides DoJump() function. After that all you have to do is make your character to use this movement component.

Note that since we have access to full source code of UE we can override/implement basically anything - including Jump functionality ; )

In the editor, you can make a blueprint from that class that has the UCharacterMovementComponent. Then in the Blueprint you can go to “Defaults” and look for the “CharacterMovement” variables. UE4 exposes the “Jump Z Velocity” variable there for you to change.


You can also just set this in the constructor for you class.


Where CharcterMovement is the default pointer variable to your UCharacterMovementComponent.

Okay awesome, thank you two for the interesting ideas.