How to make reference of MyCharacter under MyPlayerController?

I want to learn how to call a function from AMyCharacter class in AMyPlayerController ,
.h
AMyCharacter* MyCharacterRef;

.cpp
MyCharacterRef->Jump();

But this is not working .

Hello,

Are you setting the MyCharacterRef property? If not, you can use GetPawn() to get the pawn “controlled” by the controller and cast to AMyCharacter

Should look something like MyCharacterRef = Cast<AMyCharacter>(GetPawn());

You’ll want to check and make sure MyCharacterRef is valid before using it or you’ll crash the editor.

Thank You Sir for the detailed reply and help, You just solved my problem. Thank You very much.