March 2019
Intermediate to advanced
708 pages
17h 9m
English
The UPROPERTY macro we added to the class declaration is a pointer to hold the component we are using as a subobject of our Actor:
UPROPERTY() UStaticMeshComponent* Mesh;
Using the UPROPERTY() macro ensures that the object that was declared in the pointer is considered to be referenced, and won't be garbage-collected (that is, deleted) out from under us, leaving the pointer dangling.
We're using a Static Mesh component, but any of the Actor Component subclasses would work. Note that the asterisk is connected to the variable type in accordance with Epic's style guide.
In the constructor, we initialize the pointer to a known valid value by using a template function, template<class TReturnType> TReturnType* CreateDefaultSubobject(FName ...
Read now
Unlock full access