Time for action – Writing a function
For this we're going to need another custom class, an enemy spawner. We'll replace our current placed TestEnemy
actors with this new actor, and have it spawn the enemies for us.
We're going to create the enemy spawner as a subclass of
AwesomeActor
, so let's make sureAwesomeActor
looks like this:class AwesomeActor extends Actor; defaultproperties { }
Create a new file in our
Development\Src\AwesomeGame\Classes
folder calledAwesomeEnemySpawner.uc
.Write the following code in it:
class AwesomeEnemySpawner extends AwesomeActor placeable; defaultproperties { Begin Object Class=SpriteComponent Name=Sprite Sprite=Texture2D'EditorResources.S_NavP' HiddenGame=True End Object Components.Add(Sprite) }
We're adding a sprite to it so that we can see it when we place it in the editor.
Now, in order for this thing to spawn an enemy, we're going to need to write a function to do it. Let's make up a function called
SpawnEnemy
:function SpawnEnemy...