/
Timer_Example_Spawner_Header_File
62 lines (49 loc) · 3.1 KB
/
Timer_Example_Spawner_Header_File
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//-------------------------------------------------------------------------------------------------------------------
// This is a simple timer example. This asset will simply spawn a number of "Orbs" around the origin of the game -
// world. Once the selected number of assets is completed it will unbind the timer handle and wait to be removed by -
// the end play event. You can freely use this example in your unreal engine projects! Just let me know if you -
// have any questioms. -
// -
// Nicholas Mallonee -
// Unreal Engine 4.7.6 -> 4.10.1 -
//-------------------------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------------------------
// Pragmas and defines -
//-------------------------------------------------------------------------------------------------------------------
#pragma once
//-------------------------------------------------------------------------------------------------------------------
// Libraries and Includes -
//-------------------------------------------------------------------------------------------------------------------
#include "GameFramework/Actor.h" // Inheirt from the actor class
#include "Resources/StructExamples/Orbs/Orb.h" // This is the path to the object we are going to spawn
#include "OrbSpawner.generated.h" // This classes header file. Generated by the engine
//-------------------------------------------------------------------------------------------------------------------
// Class Information -
//-------------------------------------------------------------------------------------------------------------------
UCLASS()
class AI_PLAYGROUND_API AOrbSpawner : public AActor
{
GENERATED_BODY()
// -- Public information -- Constructor and engine events -- //
public:
AOrbSpawner(); // Class Constructor
virtual void BeginPlay() override; // Begin Play Event
virtual void Tick( float DeltaSeconds ) override; // Frame Tick Event
virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override; // End Play Event
// -- Private Information -- Orb Spawning -- //
private:
void handleSpawn(); // Handles the Spawning logic tree
void cleanUpTimer(); // Cleans up the timer and unbinds it
void spawnOrb(); // Spawns the orb into the game world
// -- Private Information -- Timer Handling Variables -- //
private:
UPROPERTY(EditDefaultsOnly, Category = "Run Amount")
int32 spawnerCount; // Holds the number of actors to spawn
// -- Private Information -- Orb to Spawn -- //
private:
UPROPERTY(EditDefaultsOnly, Category = "Basic Orb")
TSubclassOf<AOrb> ourOrb; // The thing we are going to spawn
// -- Private Information -- Timer Handle -- //
private:
FTimerHandle spawnTimerHandler; // The timer handle, use this for 4.7.2 on
};