Download

How do I spawn a bluerpint pawn in C++ game mode?

I tried to use my gamemode written in C++ to spawn a VR Pawn which I got from the sample project.
But I can’t assign the VR Pawn in the C++ gamemode, so I created a UROPERTY with EditDefaultsOnly, hoping I can assign the pawn in the editor. But no luck there.

Then I created a blueprint gamemode based on my C++ gamemode, but then the editor started to crash when I hit play`````````````

BTW, how do we locate our thread in this forume?

Given you created a custom C++ character class called AMyCharacter as well as a Blueprint based on that called BP_MyCharacter, you could use the following in a gamemode called AMyGameMode:



AMyGameMode::AMyGameMode()
{
    static ConstructorHelpers::FObjectFinder<UClass> BP_DefaultPawnClass(TEXT("/Game/BP_MyCharacter.BP_MyCharacter_C"));
    DefaultPawnClass = (BP_DefaultPawnClass.Object != nullptr) ? BP_DefaultPawnClass.Object : AMyCharacter::StaticClass();
}


If you need multiple classes, look into overriding the GetDefaultPawnClassForController() function in C++ / Blueprint.