GameMode via Commandline

Hello,

I would like to be able to set the game mode of my map via ?game=MyGameMode in the URL. However this only appears to set the class. Is there a way to do the same by providing the name of a GameMode asset created in the editor instead?

The reason why I don’t set it directly in the world settings is because I would have to create a persistent level per game mode unless I’m wrong and there is another way to do it.

Thanks in advance.

I think I’ve found out. Instead of having ?game=/Game/GameModes/MyGameMode.MyGameMode, I am passing ?game=/Game/GameModes/MyGameMode.MyGameMode_C which seems to get the generated class of my game mode asset. I think I am just getting confused with UClass for asset created by the editor.

1 Like

Yes, you need the _C for a Blueprint class. Another way is to use nicknames for your game modes. You set this in your DefaultGame.ini and it looks like:

[/Script/Engine.GameMode]
+GameModeClassAliases=(ShortName="MyGame",GameClassName="/Game/GameObjects/GameData/MyGameMode.MyGameMode_C")

Once you do that you can do “open mymap?game=MyGame” and it will map the alias/nickname to the full class path.

Hi,

We think this post contains useful information which we would like to share with our public UE4 community. With your approval, we would like to make a copy of this post on the public AnswerHub which includes the discussion but strips out your username and company name. Please let us know if you are okay with this.

Thanks!

Thanks for the tip for GameModeAliases. This is going to make our travel URL much shorter :slight_smile:

Absolutely. I don’t have any problem with that.