Any good C++ gamemode examples?

Hi

Recently I started learning UE4 as a game is going to support modding in the future and I want to implement a gamemode. Examples is the best way of learning for me but there aren’t that many good examples for Gamemodes, gamestates and playerstates and alot are outdated.

So if anyone has a few good examples to share that would be greatly appreciated!!

You can download the source code of this project from the “Learn” tab on launcher:

Any C++ demos from launcher will do, if you have expirance with game modes in blueprints, you practiclly know how to do gamemode in C++, you will automatically find equivalents in C++… i mean it’s same class to begin with. So check API refrence:

Note that you don’t need to mirror what other games/demos do (you probably won’t learn anything either by doing so), you should look on events and functions avable to do and use them in the way to achieve what you want to make, this is programming. Only thing you need to learn i how classes behave and avoid anything that they don’t expect and getting in there way and try to bland the code with it.

Best way to make game mode moddable is by making UT-style mutators, kind of plugins for gamemode. Make something like AMutator class with event functions that will help them manipulate the game (like forwarding all the game events optionaly you can make delegates for mutators to plug in to, it’s actully more optimal way, in game mode make function helpful for them to control the game), make array of TSubclassOf<AMutator> init them on game start, and start them up.

Alternativly you can look up UT4 source code in git hub and see how mutators are implemented there, but remember you can’t copy any code from it.

If you user want to modify on even bigger scale, they can just override gamemode, your should allow to use different gamemode classes, i mean you will need that yourself for the game eitherway. To make class more modable all functions that you want for user to be able to alter should be virtual.

Also read EULA as there restrictions of editor code distribution and use for modding the game.

Thank you for the comment and I am picking up things in my off time now and getting a better understanding of how everything works. And yeah I use examples to get familiar with the code and create my own idea using it.

Currently one thing is bothering me though AGameMode has the function GetMatchState() but AGameModeBase doesnt have it anymore? Do you know why?

Ps. The Modding part will be officialy supported by the game I want to mod, just waiting for the tools and preparing in advance

Thank you ill have a read