-
Book Overview & Buying
-
Table Of Contents
Game Development Patterns with Unreal Engine 5
By :
The template pattern exists as an extension to standard inheritance, where we define a structure in an abstract parent class and the children are given the opportunity to override the pieces of that structure. They can change how individual parts function but not the order of execution. The simplest example of this within Unreal is the AActor base class. Any child of AActor gets access to the Begin Play, Tick, and End Play events, to name but a few. The child class can hook functionality onto these events, and they will fire when expected. The constraint we place on inheritance to make this into the template pattern is that the child has no way of changing the order or timing of these events. There is no way to make End Play fire before Begin Play as this order has been defined in the parent.
We can see an example of a class implementing the template pattern in the following code. The ProcessGame() function is the only one with a body, defining the...