Making Enemies Appear

Today i did two things, spent 30 minutes activating the functionality for spells to use the player’s target object as goal and also move in the direction of the camera rather than the direction the player character is facing. Second i started implementing functionality for making classes which spawn enemies onto the level.

From the ground up there is first the Enemy itself which is an instance which looks for and attacks the player, this class is simply the blueprint class which is made earlier.

On the second level there is the spawn points which are also objects based on blueprints which can be instanced on the level. These contain a function for spawning an enemy. This is not too complicated in the Unreal 4 engine (as soon as i figured out to use SpawnAIFromCLass instead of SpawnActorFromClass). The class also checks if it is close enough to the player and sets the an internal bool to be true or false depending on the range. This is useful for the next level of command.

Finally i was originally going to make a new class to act as a manager for the spawn points to regulate the spawn-rate and selecting which point to spawn enemies from but it turned out that manager classes like these are not used this way in the Unreal 4 Engine. Instead i put the functionality for this into the GameMode class. I feel like it might be a bad idea but i couldn’t find any place which argued against the idea so i decided to go with it and keep most of the functionality within it’s own function in case i need to move it later. As of right now the class can spawn a number of enemies at a rate determined by a variable  and limited by a maximum value in another variable. This version simply gets a list of the active spawn points and picks one at random to call the CreateEnemy-function from.

Tomorrow i will see about ways to refine the two systems and apply the first on more spells and the second on the Arena map.