4.8.1 Set Default Pawn C++

I’m trying to get my default pawn class setup, but keep getting the following errors:
C2238: unexpected token(s) preceding ‘;’
C2059: syntax error : ‘=’
C2238: unexpected token(s) preceding ‘;’
C2059: syntax error : ‘=’

This is my code in the gamemode.h file:

#pragma once

#include "GameFramework/GameMode.h"
#include "testMouseCharacter.h"
#include "testMouseGameMode.generated.h"

/**
 * 
 */
UCLASS()
class GAMEMODETEST_API AtestMouseGameMode : public AGameMode
{
	GENERATED_BODY()



	ADefaultPawn = AtestMouseCharacter::StaticClass(); 
	
	
};

Hey danman1218-

When setting up the default pawn you want to do so inside the constructor of your GameMode rather than in the game mode class declaration. In this case you would need to change line 17 of your header file to be AtestMouseGameMode();

Then in the source file (.cpp) you would have

AtestMouseGameMode::AtestMouseGameMode()
{
     DefaultPawnClass = AtestMouseCharacter::StaticClass();
}

Cheers

Doug Wilson