I want to compile the answer that I have found.
First of all, this video is great, https://www.youtube.com/watch?v=ejGfHtgGOOI
It gave answers to the questions that I had the moment I opened unrealengine5 for the first time, but did not know how to formulate those questions. I wasn’t able to perfectly recreate it though, just adding files in visual studio did not work for me, but it works fine if files are added through unreal engine tools → new c++ class.
I want to add some other useful information for what I have understood. First of all, “BeginPlay” can be used as an entry, engine calls BeginPlay of every object existing in the world, additionally there are objects that do not have to exist:
- Level blueprint. Accessing it is non intuitive though, you need to press one inconspicuous button in editor which will give access to “open level blueprint”. The before mentioned video does press that button, so it can be used for reference.
- PlatformGameInstance. There is only one copy of that object, so its great for entry, it is created the moment you press play. I would consider this the most universal entry point. Instead of “BeginPlay”, the entry has more intuitive name “Init”
- GameModeBase. Its the entry point that is used in many free examples. It is tied to the level, when ever a level opens, it runs game mode associated with it. To add game mode to a level, one needs to select the level in content browser and on the right → world settings → GameMode Override.
In unreal engine, you can select the defaults for those classes by going to Edit → Project Settings → Maps & Modes. There you can select default Level which in there called “Game Default Map”, you can also select default game mode and default game instance.
PlatformGameInstance is superior entry point, because in there, you could connect “OpenLevelByName” to the “Init” and have a game mode override connected to the level that you are opening, only data stored within game instance is transferred between different levels, everything else is terminated and lost. Though, it does open the default level and game mode and runs their BeginPlay, before it runs Init in game instance(not exactly, its kind of weird what it does).
Additionally, the most useful hotkey to know is ctrl+alt+f11 which makes a quick recompile refresh in unreal engine editor after you change source code.