Game Mode override on dedicated server

Hi everyone, hope you are having a nice day.

I’m trying to do a multiplayer game with a dedicated server:

Basically you have two maps.

  1. Menu
  2. Game

By default we have the game mode that will be used in Menu and then the gameLevel overrides the game mode with another one.

This is my network setup:

If I run I get access violation as soon as I call one of my functions of the game mode if this function tries to use any of properties, like it never initialized.

//.h

USTRUCT()
struct FPlayerInGame
{
	GENERATED_USTRUCT_BODY()
	UPROPERTY()
		FString playerName;
	UPROPERTY()
		int nWins;

	UPROPERTY()
		APawn* pawnRef;

	FPlayerInGame() {
		playerName = "UNKNOWN_NAME";
		nWins = 0;
		pawnRef = NULL;
	}
	FPlayerInGame(FString newPlayerName, APawn* player)
	{
		playerName = newPlayerName;
		nWins = 0;
		pawnRef = player;
	}
};

class MyGameMode...etc

UPROPERTY()
		TMap<uint32, FPlayerInGame> playersInGame;

//CPP
void AHoldTheBallBattleGM::RegisterPlayerReady(APawn* playerReady)
    {
    	UE_LOG(LogTemp, Warning, TEXT("[SERVER] Received Player Ready %s"), *playerReady->GetName());
    
            // PlayersInGame Contains causes access violation
    	if (playersInGame.Contains(playerReady->GetUniqueID()))
    	{
    		UE_LOG(LogTemp, Error, TEXT("[SERVER] Got duplicated!"), *playerReady->GetName());
    		return;
    	}
}

Because I’m able to call functions on my game mode it looks like I’m definetly using the right one. but TMap is not properly initialized, and it is when I put it as main game mode. :confused:

Anybody has any clue on what’s going on?

Thank you!

Update: Is not because of the TMap. I’ve also tried to have an int. initialize it on the constructor and then print it when I call the function and it will show the value properly but it will crash right after.

ICan’t show the crash itself because it says I don’t have the symbols loaded for it and I have pragma optimize ("", off)

Update2: I forgot to mention that this function is called on BeginPlay of each pawn

If Role == Authority
Call Func();

I’ve seen that if I called after, with “press O and then call func” it works!

is Game Mode BeginPlay being executed after pawns causing the error? then why does not happen if I set the game mode as main?

Update 3: In my main game mode. the one is set on the Project Settings, I have specified a custom player controller that shows a custom widget.
Now when I click play on my battle level I can see the widget appearing and dissapearing right after, which means is first trying to use the main game mode and then is being overrided!
If the widget is showing up I’m probably going through beginPlay at that point! so that could be the issue.

No clue how to deal with it though.

Solved: I didn’t do Super::BeginPlay()… and was causing all kinds of issues.

How did I miss that…