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:
- 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...