I have a player pawn defined in my gamemode blueprint object. How do I get a reference to this pawn in C++?
I then want to cast it to super class “VR_Pawn”
I have a player pawn defined in my gamemode blueprint object. How do I get a reference to this pawn in C++?
I then want to cast it to super class “VR_Pawn”
After some trial & error I found the solution:
class AVive_testGameMode *myGameMode = (AVive_testGameMode*) GetWorld()->GetAuthGameMode();
class AVR_Pawn *myPawn = Cast<AVR_Pawn>(myGameMode->DefaultPawnClass.GetDefaultObject());
I was just browsing looking for a similar solution to the problem you had.
The problem with your solution that I can see is that you hard coded a specific game mode and pawn into the C++. That can’t be the best practice, can it? What happens when you change that sort of thing in the Editor, won’t that break the code?