For this recipe, we will create a building that spawns units at a fixed time interval at a particular location.
Creating a building that spawns units
How to do it...
- Create a new Actor subclass in the editor, which we will name Barracks:
![](https://static.packt-cdn.com/products/9781789809503/graphics/assets/7df75b09-439e-41bc-b8e7-a5c519efe1fd.png)
- Then, add the following implementation to the class:
UCLASS()
class CHAPTER_04_API ABarracks : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
ABarracks();
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
UPROPERTY()
UStaticMeshComponent* BuildingMesh;
UPROPERTY()
UParticleSystemComponent...