How does IMPLEMENT_PRIMARY_GAME_MODULE( FDefaultGameModuleImpl, TutorialCode, "TutorialCode" ) work?

I’ve written a GridDriver class that instantiates an object of type CustomGrid which is a TArray of CustomPoint Structs which are FVectors + a boolean, but I don’t know where I will call it from within my game to let it do it’s work.

With the tutorialGame code downloaded after watching the tutorial series beginning with this video: - YouTube, there is a file called TutorialCode.cpp that has this as it’s only line: IMPLEMENT_PRIMARY_GAME_MODULE( FDefaultGameModuleImpl, TutorialCode, “TutorialCode” )

Similarly, my base game file that I am working with has this as it’s only line: IMPLEMENT_PRIMARY_GAME_MODULE( FDefaultGameModuleImpl, GameName, “GameName” );

Does the engine know to automatically look for things prefixed by the string set here (GameName for my example, TutorialCode for the video’s)?

How does IMPLEMENT_PRIMARY_GAME_MODULE( FDefaultGameModuleImpl, GameName, “GameName” ); work?

For example, to match TutorialCode there is TutorialCodeCharacter.cpp, TutorialCodeGameMode.cpp, and TutorialCodeHUD.cpp, but I don’t see how TutorialCode.cpp is creating instances of these other things and calling their methods.

In visual studio, I went to the Debug tab, and clicked step into to try and determine what is going on, but as far as I can tell the code being stepped into is only related to launching the editor. I just tried setting a breakpoint at IMPLEMENT_PRIMARY_GAME_MODULE( FDefaultGameModuleImpl, GameName, “GameName” ); to see what gets called next and it gave me a symbol loading error. Anyway, I just need some help figuring out from where I can instantiating my GridDriver.cpp class and call its Drive() function that orchestrates the rest.

Thanks a bunch.

What’s the first line of code that runs when my game runs that is a part of the game I’m developing and not part of the engine, was I wrong in thinking that it is “IMPLEMENT_PRIMARY_GAME_MODULE( FDefaultGameModuleImpl, GameName, “GameName” );” ?

I’m trying to find out where I can set a break point to step into execution and observe the execution flow of my game code, how to hook into it as early as possible, in order to further my understanding.

If I create a new file called TestGameMode.cpp , how do I tell my GameName.cpp file to look to that file for it’s GameMode definition as opposed to some other file?

unrealEngine.CPP seems to be the place everything starts.
UEngine::Init() might be a good place to start…
UEngine::LoadGametypeContent() sets the game mode.

if you want a gamemode to be used by your game, you can set that in the editor’s project settings > Maps and Modes > Default Game Mode. and if you set it to a blueprint version of a game mode, you can change the default pawn/hud/controller/etc…