top of page

Week 8 - Upgrading the enemy behavioural state system and creating terrain

This week I focused on upgrading the enemy state behavioural system. I created a function which took in 7 parameters. These were as follows:

  • Proximity > The distance between the player and the enemy

  • Boid > addressed the specific boid in the ‘for loop’

  • alertLevelRate > Gets higher depending on the proximity to the player

  • panicLevelRate > If the alertLevel is at its max, then the panic level increases. The higher the panic level the faster the enemy will run

  • staminaLevelRate > Stamina depletes when the panic level increases. The animal can sprint away as long as they have stamina

  • distanceVisible > Used for a raycast to define the visible distance between the enemy and player.

  • I added three image UI’s to the animal prefab. One for Alert Level, Panic Level and Stamina Level. I used the fill values of these images to control behaviour of my enemies within the script.

I then cast a ray from the enemy position towards the player position. The distance of the ray was defined by the ‘proximity’ variable.

If the player was visible and within a certain proximity to the player then the enemy alert level would increase. The rate of increase was defined by how close the player was to the enemy. If alert level reached 100% then the panic level increased. The higher the panic level the faster the speed of the enemy. The stamina level depleted while the panic level increased. Enemy’s could only run fast while the stamina levels were above 0. If the stamina reached 0, enemy’s would return to their wander waypoints. This gave the player a chance to attack enemies.

I found it challenging to create the various behavioural variables within which would be activated depending on the state of the enemy’s current position relative to the player. However, as I created all the functionality in the base class, it allows me to easily adapt variables such as visible distance and enemy speed in the child classes.

Although the states need some minor tweaks, the general behaviour of enemies now works as intended.

I then began creating the terrain assets on blender. As I had previously designed the animal models, I found it easier to pick up this time. I created a terrain gameobject within Unity and textured it using a 2D image. As I wanted to use a normal map of the texture to create a depth effect, I downloaded a software called ‘Crazy Bump’ which allowed me to generate a normal of 2D images. I then created different colours of the 2D ground texture to represent different colours of grassland. I was able to use the same bump map for all.

Then modeled a low poly rock within blender. I started with a sphere and used the bisect tool to slice edges off until I had a low poly rock shape.

In the following week I will be focusing on designing the entire map using assets created myself. I will additionally clean up my code and fix bugs. As I there will be a play testing session next week, I plan to add a start menu and end game menu and attempt to export it to mobile to get a playable game.


Recent Posts
bottom of page