Adding components to the new actors
Unreal provides useful components that can be added to actors; for example, you can add a static mesh component to an actor so that the actor is visually represented in the game levels. In our case, we want to add a box collision component and a static mesh component to ADefenseTower and AProjectile, as follows:
UBoxComponent: This is added as the actor’s root component for collision detectionUstaticMeshComponent: This is added as the child of the actor’s root component, which allows us to select and display a 3D mesh in the game levels
To use these two components, you should include their header files at the beginning of ADefenseTower.h and AProjectile.h files.
Including component header files
The order of #include statements in C++ is not a big concern, but you should ensure that the *.generated.h statement is placed as the last include statement and right before the UCLASS definition.
Here is the example...