How do I set Default Pawn as SpectatorPawn using a blank C++ template?

I’m orientating myself on the Blueprint Card game example.

I set up a blank C++ Project and added a blank map to experiment on.

I want the camera to be fixed and the Pawn not being able to move with WASD.
In the World Settings I changed the GameMode to MyGameGameMode which was created by the template as C++ Class, but I can’t change the DefaultPawnClass to SpectatorPawn like in the Card Example, the dropdownlist is grayed out.

I added the blueprint commands to set the player controller transform to the player start transform on beginplay, but rotation is ignored.

The template also added MyGamePlayerController and sets it in the Constructor of my GameMode as PlayerControllerClass.
Now I assume this one is making WASD work and move, which I do not want.

How do I set a SpectatorPawn as DefaultPawn in C++ so I can set the Controller to a fixed position (including rotation) and have a static view without being able to move?

First, create a new class derived from ASpectatorSpawn.

In the constructor, set bAddDefaultMovementBindings to false;

AMySpectatorPawn::AMySpectatorPawn()
{
    bAddDefaultMovementBindings = false;
}

In the AGameMode class, in the contructor, set the default pawn class to your new spectator pawn.

AMyGameMode::AMyGameMode()
{
    DefaultPawnClass = AMySpectatorPawn::StaticClass();
}

It should work. :slight_smile: