Jump in C++ Code without Jump()

I have asked this question before but it gave me no answers so i’m reposting and rephrasing it. In my character class, called MainCharacter, I am assigning simple input functions to it e.g. looking, moving left,right,forward,back etc. However, I cannot seem to find a way to change Z velocity to make the character jump in code. I’ve tried:
void AMainCharacter::Jump() {
GetCharacterMovement()->Velocity.Z = 3000.f;
But this does nothing. I presume what this is doing is just getting the movement component, changing a value and not reapplying the changes to the original character movement component.

Also, I do not want to use the simple jump function:
I actually want to know what is happening in my code so I understand it better.

Hi. I think why you are see this is because its calling the ThirdPerson_AnimBP. Did a little digging (at work) on the Character.cpp and there is some code that appears to be calling AnimBP. For example, I see a ResetJumpState and if CharacterMovement->IsFailling() – Which is in the AnimBP that has a state called IsFalling.

I’m pretty sure that’s why you are not seeing anything more specific in terms of VelocitZ = 3000f.

Hope this helps.

I see below too… Might be right and me wrong.

The problem is that the CharacterMovementComponent won’t use the Z-velocity as long as you don’t also update it’s MovementMode like so:


I’m not entirely sure how the Z-velocity would be handled without changing the MovementMode if your Character doesn’t walk/stand on a horizontal plane, but I’m sure you could test that yourself.
And as a tip, you can also(if you have the engine-source installed from the launcher) right click on the Jump() function in Visual Studio and then choose “Go to declaration”. That way you can figure out how something is implemented/works without having to reinvent the wheel.

Thanks! That’s really useful!