Is there a function called when a map is first loaded?

I am hoping to discover the name of a function that is called when a new map is loaded (via “Server Travel”).

Is there such a function and does it take into account the name of the name or anything similar to help determine what code to run based on what map has just started.

Thanks,

Dingo

From the UE4 Documentation: GameMode

The AGameMode class defines the game being played, and enforces the game rules. Some of the default functionality in AGameMode includes:

InitGame:
The GameMode's InitGame() event is called before any other scripts (including PreInitializeComponents() ), and is used by the GameMode to initialize parameters and spawn its helper classes.
This is called before any Actors' PreInitializeComponents, including the GameMode itself

PreLogin:
Accept or reject a player attempting to join the server. Fails login if you set the ErrorMessage to a non-empty string. PreLogin is called before Login. Significant game time may pass before Login is called, especially if content is downloaded.

PostLogin:
Called after a successful login. This is the first place it is safe to call replicated functions on the PlayerController.
Any new functions or variables that set game rules should be added in a subclass of the AGameMode class. 

Anything from what inventory items a player starts with or how many lives are available to time limits and the score needed to end the game belongs to GameMode. A subclass of the AGameMode class may be created for each gametype the game should include. A game may have any number of gametypes, and thus subclasses of the AGameMode class; however, only one gametype may be in use at any given time. A GameMode Actor is instantiated each time a level is initialized for play via the UGameEngine::LoadMap() function. The gametype this Actor defines will be used for the duration of the level.

As for getting the map name… also from the UE4 Docs: UWorld::GetMapName

So from any actor in your scene, including the AGameMode:

GetWorld()->GetMapName()

This should get you on the right track… if it’s not exactly what you were looking for =)