Enemy Behaviors and Spawning


“Enemy Behaviors and Spawning”

author: Joseph Horsch

Posted on 4/25/2025

Enemy 1 Behaviors

The First enemy behaviors there are three things: Idle, walk and attack.  

Idle is when either enemy can't reach a target or a target does not exist in the world.  To make sure that the enemy always has a target in the world on initial spawn of the enemy by either spawning or by being placed in the world the enemy will grab the potential targets of the class player and grabs the first one.  This will be modified when we get multiplayer up and running to grab a player class at random.  

Chase Player behavior is the basic move to function for the enemy to go to the player.  When the enemy has a target initialized if target can be acquired on the Nav mesh then enemy will go to the desired target and stop with in one meter.

Attack behavior is a basic melee attack, enemy will swing towards the target and try and deal damage when enemy is close to the target.  To make the Attack behavior deal damage to the player a box collider is spawned in front of the enemy by an anim notify in the attack animation.  this choice is to not need to place a damage collider on the hand of the enemy since future enemies would need to be modified to do the same.


Basic Spawner


The basic spawner which is currently represented as an arrow at the current moment spawns an actor at its relative location.  This will normally be placed off screen allowing enemies to spawn in and not worry about with a spawn animation.  In future iterations of the spawning I do plan on adding the ability with spawn animations when we desire to spawn an enemy in front of the player or in the view of the player.

Animation problems

Animations were a problem. Probably due to that I'm not an animator.  When initially setting up the behaviors I struggled with setting up animations.  I was currently trying to set up animations not designed for the skeletal mesh and was getting weird results that either squished the actor, stretched the actor or broke certain bones.  In the two videos above you might see that the animation is not designed for that model.  Due to too much time being spent on animations my future works I will be swapping to mixamo models/animations till we get a proper animator and model rigger.


What I am Working on Next

Since we now have our first enemy and spawner I will be working on the gameplay loop.  This is very similar to a zombies game with waves I will be setting up a way for the spawners to communicate to the game mode to see if spawning is possible or not so that we can communicate the current wave and how many enemies is need to be defeated per wave.

Leave a comment

Log in with itch.io to leave a comment.