Use this as a roadmap for learning scripting
- Game Mode
- Game Instance
- Player controller
- Scriptable Objects
- Player state
- Game state
But before heading into creating your first level, you need to learn some theory about the event system.
The classes in the list above are what we refer to as gameplay classes. Every gameplay class has 1 thing in common with all others, the common event functions listed below:
virtual void tick(float deltaTime);
virtual void beginPlay();
virtual void endPlay();
These functions are going to be called automatically when needed
The tick function will get called every frame until the death of the given class
The beginPlay function will only be called when the class is created for the first time
The endPlay function will only be called when the class is near destruction, for the reasons listed below
- A level was opened
- The application was closed
- The given class had to be replaced by another
Constructor and Destructor
The constructor should only be used for initialization of variables or for functionality that isn't dependent on the engine's features, while the destructor needs to be able to fully reset the class. You ABSOLUTELY NEED to make sure your destructor leaves your class in the same state as it would be if it were created as a new variable. Additionally, make sure you're not executing heavy and slow operations.
For performance reasons, the engine pre-initializes and instance of every gameplay class. The
UVKBuildTool takes care of generating code that initializes all the gameplay classes on the stack. This way, we have most of our internal data stored as stack pointers, instead of as heap allocated ones. Essentially, this moves all data from the gameplay classes closer to the CPU cache and makes read/write/access operations significantly faster. Due to this, however, we cannot trivially delete classes as we could with heap allocated data and are forced to essentially reuse old classes if needed, which is why we need you to fully clean up all your data.
The hierarchy of classes looks like this:
You might notice that one class is missing, and that is the
Scriptable Object class. This is because they are independent of the hierarchy and are entirely owned by the engine's systems.
So as you can see there is a clear division between all types of gameplay class, so choosing the right one for the job is critical to your application's inner functionality
- Beginner concepts
- Advanced concepts
- Engine developer and contributor resources