I updated my enemies with a simple behaviour:

  • defensive will hide when hit once,
  • balanced hides when too much damage is taken,
  • agressive doesn’t care,
  • if ammo clip is empty hide and reload

The enemy has several states which it can use:

  • Spawned,
  • Run,
  • Hide,
  • FindCover,
  • FindPlayer,
  • Shoot,
  • Dead
Visualization of how the nodes are connected

With this there is already some sort of behaviour to the enemy which already helps the level to be more interesting.

I added my A* pathfinding algorithm to my enemies. This system is based on my waypoint system that I created in the previous updates of my project. I had issues with the correct pathfinding due to a small error in my script which overwrote my original path, but once that was corrected the script ran just like it is designed to.

Presented here is a small part of the pathfinding algorithm method, this is the method that will keep going through all the waypoints until the goal is found OR there are no waypoints left to use.
To know about this part of code:

  • openList, visitedList and reachList are all lists which keep track of the pathfinding algorithm items. openList is used to keep track of the still to process waypoints specifically, visitedList contains all the waypoints that we already visited and are not usable anymore. reachLine is the only List that is used merely for the end result of our algorithm, it contains the final path or stays empty when no path is found.
  • I reverse the reachList before returning is to set the List correctly that my unit can directly use this List for following the path.
  • CheckPath(Waypoint wp, float newCost, Waypoint parent) checks if the waypoint wp is a path which is worth to follow or not
  • ContinuePath(Waypoint destination) is a looping method, but has two exits by returning. The first return is triggered when we don’t have any new waypoints we can test (and as an extra safekeeper when foundGoal is true) and the second is triggered when we found our goal and created our path to follow.

ContinuePath method

Since I already had my project started before creating a website, I will put the current updates in one post.

The Hunted Update 5

The Hunted - waypoint system
I made a small tool that will generate a grid based on the waypoints in the level, first I wanted to use the A* algorithm to find all the waypoints that could connect. But after a small test I found out that this is not the best way to start making the grid. After some research I found that a distance based algorithm would be the fastest way to start creating this grid, which will make a good base to work out the grid even more with A*.

The Hunted Update 4

waypoints
Currently working on a waypoint grid system. At this point it raycasts 360° on the Y-axis to collect all the “visible” waypoints. Using A* with unlimited raycast length takes too long to find all the paths the enemy can take over the grid. Having issues with the SetDirty(object) method due to not firing correctly in the tool. Using SetDirty should enable Unity serialization and saving so that the waypoint grid will be cooked/baked into the level so that I don’t have to set them all manually. The waypoints become invisible and untouchable when the game is started, so they won’t be having an effect to the gameplay.

The Hunted Update 3

level
Created a simple level (part 1 out of 5) to run around in which has multiple dead spots and bottlenecks. This will influence the gameplay, the game is a survival game so the player should be able to get into a tight fit when playing the level.
Updated the recoil for the base weapon, created the base for the gametype, added visual feedback for the weapons, life, time and game info.

The Hunted Update 2


Created a base weapon which makes it possible to make and change weapons quickly. Added weapon inventory system and RPG assets for upgrades. Changed the camera type from third person to first person.

The Hunted Update 1

Start of the project. Thinking out what kind of game it needs to be, what the current goal of the project is.

Set up a scene with a simple playercontroller which has movement and aiming. Started on making a script for the base weapon.