Functions in GameMode.cpp not running

Not sure why none of these functions are working. I know it’s set to the correct GameMode under project settings because the game using code from the constructor successfully. I never see anything from these functions appear on the screen

ATypingRunGameMode::ATypingRunGameMode(const FObjectInitializer& ObjectInitializer)
	: Super(ObjectInitializer)

{
	// set default pawn class to Blueprinted character
	static ConstructorHelpers::FClassFinder<APawn> PlayerPawnBPClass(TEXT("/Game/Blueprints/MyCharacter"));
	if (PlayerPawnBPClass.Class != NULL)
	{
		DefaultPawnClass = PlayerPawnBPClass.Class;
	}

	//Set the default PlayerController class
	PlayerControllerClass = ATypingRunPlayerController::StaticClass();

	//Set the default HUD class
	HUDClass = ATypingHUD::StaticClass();

	PrimaryActorTick.bCanEverTick = true;
	PrimaryActorTick.bStartWithTickEnabled = true;
}


void ATypingRunGameMode::Tick(float DeltaSeconds)
{
	Super::Tick(DeltaSeconds);
	GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("Tick function"));
}

void ATypingRunGameMode::BeginPlay()
{
	Super::BeginPlay();
	GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("Test"));
	SetCurrentState(ETypingRunPlayState::EPlaying);
}

Any idea?

Hey, remember to make sure in the header file that you’re overriding the BeginPlay function. The following below worked just fine for me. If you’re still running into any snags be sure to let me know. Also, double check to make sure you’re actually ‘running’ your game mode.

    class A<YourClass>: public AGameMode
    {
    	GENERATED_UCLASS_BODY()
    
    
    protected:
    	void BeginPlay() override;
    
    };
    
    A<YourClass>::A<YourClass>(const class FPostConstructInitializeProperties& PCIP)
    	: Super(PCIP)
    {
    	// set default pawn class to our Blueprinted character
    	static ConstructorHelpers::FObjectFinder<UClass> PlayerPawnBPClass(TEXT("Class'/Game/Blueprints/MyCharacter.MyCharacter_C'"));
    	if (PlayerPawnBPClass.Object != NULL)
    	{
    		DefaultPawnClass = PlayerPawnBPClass.Object;
    
    	}
    }
    
    void A<YourGameMode>::BeginPlay()
    {
    	GEngine->AddOnScreenDebugMessage(-1, 5.0, FColor::White, FString::FString("I am working!"));
    }

Huh, that’s odd. I just switched my PC back on again and everything is working perfectly…maybe the hot reload wasn’t working properly? Anyway, that’s the problem solved. Thanks for taking the time to reply anyway!

Restart of PC fixed the problem. Hot reload was possibly failing.