How to make Character jump from PlayerController using C++ and enhanced input?

Hello!

I’m fairly new to Unreal Engine and trying to learn by doing small things I’ve run into a problem.

I’ve managed to write the code to move the character and look around from the PlayerController but I don’t see a way to do the jump action.

I know that the ACharacter implementation provides a Jump and StopJumping function. Is there any similar way to do it from PlayerController?

Thanks in advance!

I know that the ACharacter implementation provides a Jump and StopJumping function. Is there any similar way to do it from PlayerController?

For such tasks you usually goes to entity that can do work and do work here. Considering jump from controller, it’ll be getting a possessed pawn, casting it to character and calling jump here:

void AMyPlayerController::MySuperJump()
{
	ACharacter* Character = GetPawn<ACharacter>();
	if (!IsValid(Character))
		return;
	Character->Jump();
}
1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.