Set DefaultPawn as DefaultPawnClass

Hi everyone,

So I’m looking for a simple RTS camera.
Basically, DefaultPawn already comes with all the key ingredients for being such camera, as inputs and movement are already set in its CPP file.

Only question remains is: why can’t I make it a DefaultPawnClass in the GameMode?

Here is the GameMode.cpp:

AVikingKingGameMode::AVikingKingGameMode(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer)
{
	// set default pawn class to our Blueprinted character
	static ConstructorHelpers::FClassFinder<APawn> PlayerPawnBPClass(TEXT("Pawn'/Game/TopDown/GameCamera/GameCamera.GameCamera_C'"));
	if (PlayerPawnBPClass.Class != NULL)
	{
		DefaultPawnClass = PlayerPawnBPClass.Class;
	}
}

Both my camera class cpp and h files are empty.

Image for the Blueprint I made of the camera class location is attached.

Thanks.

It is probably a good practice to keep blueprints as children of code classes, and set the default pawn of a blueprinted game mode as your blueprinted pawn class. You can have each of these be a child of a class you made in cpp so you have the functionality of both worlds at your fingertips. I don’t think you want to have a blueprinted class as the default pawn class of your cpp gamemode class.

@Spiris I understand. It also seems to work when I deactivate the usage of the DefaultPawn inputs, and use my own ones.

How do you suggest using the Bluprinted camera class as default pawn in the GameMode, while the template itself produces a code version of the GameMode (thus not allowing me to use a blueprint)? Should I make a blueprint of the C++ GameMode that is created with the template?

You got it Kostor, that should allow you to set up the default pawn in blueprints and give you access to a whole lot of other easy modifications.

Thank you so much for your help, I’m marking this entry as answered for now.

Please advise the comments above this answer.

IMPORTANT: When using the DefaultPawn, you should blueprint it, and the GameMode. This way, you can set you blueprint of the DefaultPawn as DefaultPawnClass in the GameMode.

Glad I could help, feel free to ask any followup questions as necessary.