Declaring the default pawn class in GameMode

Hi there guys!
Sorry for the really noob question, but I want to declare the class with the default Pawn in the GameMode
directly in C++ (since in my project it wouldn’t change).
And I challanged myself to create the whole project without a single blueprint (execpt of the really really simple stuff, like doors or moving platforms).

So as fat as I understood, There is a UPROPERTY in the AGameMode.h class that should get the default pawn class (DefaultPawnClass), and it’s type is APawn.
So my question is, how do I get the path for the class? (Without fstream.h of course :p).
I saw that it might be achived by using the ConstructorHelpers::FObjectFinder

Here is the code I’v tried (the syntax is probably incorrect):

static ConstructorHelpers::FObjectFinder<APawn> pawnClass(TEXT("class'Game/Source/HP/HPCharacter.h'"));
	DefaultPawnClass =  pawnClass;

So how can I do that?

I think the preferred method is to set it to a BlueprintClass that is of your custom class type, so that you can then easily edit it within the editor rather than having to always edit code to change settings. For example this is done in the FirstPerson template:

static ConstructorHelpers::FClassFinder<APawn> PlayerPawnClassFinder(TEXT("/Game/Blueprints/MyCharacter"));
DefaultPawnClass = PlayerPawnClassFinder.Class;

Where the template has created an instance of TP_FirstPersonCharacter as a blueprint called ‘MyCharacter’.

Thanks for the reply, but as I’v said, I’d really like to create the core foundations of the game without any blueprints… Also, Most of my code was inspired by the TPS Template, and I’v got the idae of the DefaultPawnClass from it :slight_smile:

You can try:

DefaultPawnClass = AMyCharacterClass::StaticClass();

What is DefaultPawnClass for? I have problem with it. You can see it here: Another player appears in the place I am before I click play in the editor - C++ Programming - Unreal Engine Forums

Assumed that your game mode file(called as MyGameMode.h) is in Source folder, so you have to include HPCharacter.h, and declare like below.

         #include "HP/HPCharacter.h"
          AMyGameMode::AMyGameMode()
        {
             DefaultPawnClass = AHPCharacter::StaticClass();
        }

For either FObjectFinder or FClassFinder, these are used to find Blueprint layer from the game folder, aka Content folder in the project.