Set default blueprinted pawn from C++

Hello there,

I started a new project from the C++ Topdown Template and am having trouble selecting a different pawn class.
Basically I want a Blueprint extending my C++ character class to be my default pawn.
I thinks this line in GameMode.cpp is responsible for that:

static ConstructorHelpers::FObjectFinder PlayerPawnBPClass(TEXT(“Class’/Game/Blueprints/MyCharacter.MyCharacter_C’”));

I already tried changing it to the path of my own blueprinted character:

“Class’/Game/Sprites/Blueprints/HumanCharacter”

but this one does not work, the editor always opens up a crash report for me when I try to open this project.
This one as a path works though:

“Class’/Game/Sprites/Blueprints/HumanCharacter.HumanCharacter_C’”

What does the .MyCharacter_C’ / .HumanCharacter_C’ at the end of the path mean?

Thanks for reading!

Hi,

i’d avoid hard-code references in the code.

It would be better to create blueprint based on game mode class, set default classes inside that blueprint and then set blueprint-game-mode as default for your game.

Regards.

The path you want is found by right-clicking on the blueprint and clicking on ‘Copy Reference’ so that you can paste the copied string into the TEXT(String) method easily.

As far as I know, you cannot reference one Blueprint in another, so if he has a Character blueprint, the only way to use it is to assign it from code.

To answer your specific question, the “_C” part is appended to the Blueprint class generated by the engine.

Further clarification:

Adding “_C” will mean that the object finder will return an object of type “BlueprintGeneratedClass”, i.e. a class reference, not a Blueprint object instance reference. Hence something like “Cast(yourClassObject)” will be required.

TSubclassOf will work just fine.