Download

Game Mode: call StartPlay when second map is loaded

I’ve just started to learn Unreal Engine 4.26.2 and C++.

I have two maps: one used only to show the main menu, and another one to play the game (Pong clone).

On my GameMode, which inherits from Game Mode Base, I have implemented method Start Play. My problem is that method must be called when the player enters into the game (when the second map is shown), but that method is called when the game start.

Is there any method to call when the second map is loaded? I have thought to call a custom Game Mode method from second map level blueprint.

StartPlay in GameMode should trigger whenever a new map is loaded, not just when the first map is loaded.

Make sure your main menu is in another map than your game map. Make a blank map for your menu widget.

I’m suspecting that you might handle some data in your GameMode that should really go into the GameState. Take a look at these two links:

Thanks for your answer.

Yes, there are two maps: one for the main menu, and another one for the game. First, opens the main menu map. When player click on start game option, it opens the game level map. But GameMode->StartPlay runs on the Main Menu Map and I want to run this method (or another custom method) when Game Level Map opens.

In addition, the documentation about what is Game Mode and Game State is too poor. It seems like I need to know about Unreal to start learning Unreal.

I’m migrating this C++ code to Blueprint just for learn: Pong/PongGameModeBase.cpp at Develop · ViaCognita/Pong · GitHub

There you can check what I’m doing.