The game instance class is created on the installation of the project. It functions as a persistent class to manage global application states. For example, you might use the game instance to store player names, playtime, load and unload player save files and more.
The game instance is the first class to be created after the engine is started up. Unlike other gameplay classes, it has no tick event, since other classes should read and write to the data contained in the game instance.
As said previously, the game instance contains 2 out of the 3 universal events
beginPlay- the “begin game” event
endPlay- the “end game” event
init- the “init” event is called as the first part of the events pipeline
destroy- the “destroy” event is the last event to be called as part of the events pipeline
But it also contains a third event used for editor modules called
onEventInitEditorModules. Here, you can call any function to activate an editor module. More documentation on editor modules can be found here.
Functions and variables
exit function closes the application
currentLevel function returns a pointer to the currently open level
The initInfo member variable contains a bunch of data that serves as a type of config that the engine uses on startup. You can learn more in this wiki entry.
You can use the standard casting function to cast a generic pointer to a pointer of its base type
- Beginner concepts
- Advanced concepts
- Engine developer and contributor resources