Search code examples
c++unreal-engine4

Change GameMode on GameStart


I have a question about this function:

UWorld::SetGameMode

I have let's say 3 GameModes. How can i get access to them in my code and set one of them as default when game starts? What is the best way to do this?


Solution

  • You can use your own UGameInstance class (set it in the project settings). In this class you can override this method:

    /** Call to create the game mode for a given map URL */
    virtual class AGameModeBase* CreateGameModeForURL(FURL InURL);
    

    And supply whatever gamemode class you wish to use.