Tell GameMode to use PlayerPawn not working.

**edit: Found the solution on my own. For anyone who is having the same problem, heres the solution:

When you copy the blueprint reference you get a path that looks something like this: Blueprint’/Game/Blueprint/BlueprintCharacter.BlueprintCharacter’

The simply solution is to delete the double name, so that only Blueprint’/Game/Blueprint/BlueprintCharacter’ is left. Than you have simply to put it into the code line, so that unreal knows which blueprint you try to access.

Hope this helps :).
**

Im currently doing the c++ tutorial from the offical documentation.

Everything works fine, except that i need to replace the DefaultPawnClass with a Custom Mesh.

Before i used to load my DefaultPawnClass in the GameMode.cpp

** DefaultPawnClass = AFPSCharacter::StaticClass();

later, the tutorial says, that i should replace it with:

// set default pawn class to our Blueprinted character
static ConstructorHelpers::FClassFinder<APawn> PlayerPawnObject(TEXT(“Pawn’/Game/Blueprints/BP_FPSCharacter.BP_FPSCharacter_C’”));
if (PlayerPawnObject.Class != NULL)
{
DefaultPawnClass = PlayerPawnObject.Class;
}

I changed the path of course to my own blueprint refrence. I get no errors when i compile/build it, but it doesn´t load the mesh and sets my input back to normal (which means i can fly around instead of walking, jumping etc.). Basicly it isnt calling my Character.cpp anymore (did a debug log).

Any ideas what could cause something like that? Im using 4.9.

You won’t get any errors because the pawn class can be null while compiling without problem. if TEXT(“Pawn’/Game/Blueprints/BP_FPSCharacter.BP_FPSCharacter_C’”) gives an invalid path or the object does not exists the compiler will still not complain during compilation phase, do check if PlayerPawnObject.Class is null.

Also Please refrain from using paths directly like that , its highly discouraged and makes code messy over time. Use a blueprint set able UPROPERTY instead.

U mean with UPROPERTY this:

UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Classes)
TSubclassOf< class APawn > DefaultPawnClass

?

From what i understand is that my “method” aren´t supported by the engine anymore. But i haven´t really found a different way to call my blueprint mesh as default pawn class.

U mean the method using the ClassFinder? and why would this not be supported anymore?
This method is also used in pretty much every UE4 c++ tutorial / template i seen so far.

As for changing the the reference string from the editor, i just use the asset path and this works fine:



static ConstructorHelpers::FClassFinder<APawn> PlayerPawnObject(TEXT("/Game/SwatAssets/Blueprints/Pawns/BP_DefaultPlayerPawn"));
DefaultPawnClass = PlayerPawnObject.Class;


Yes exactly, It will also maintain a dynamic reference to your class and updating paths when needed instead of bloated and hard coded path