• About
  • Games
  • Asset Packs
  • 3D Art
  • Environments
  • Game Studies
  • Blog
Stefan Dolidis
  • About
  • Games
  • Asset Packs
  • 3D Art
  • Environments
  • Game Studies
  • Blog
Stefan Dolidis

1. FPS GAME - ENEMY BEHAVIOUR

15/7/2021
Picture
Creating an 'old-school' FPS game. At this stage, I'm focusing on the game's enemies.
Enemies in game have multiple 'behaviour' states and animations that go with each. Behaviour states are what the enemy does at one given time. The main States are Spawn, See, Attack, Pain, and Death.

Spawn: Enemy spawns in (gameobject is enabled). Enemy waits 2 secs, and then proceeds to do its first task.
See: The enemy has detected the player and will proceed to a position where it can attack the player.
Attack: Is in attack position, starts to attack the player. (Attack!)
Pain: Has been hit and is knocked back (stunned).
Death: Health <= 0. The enemy has been defeated.

​There are plans to have more behaviour states, like, for example, being Frozen or on Fire. Currently, I'm using a switch statement to handle all the states. The plan is to have around 7 enemies in the game. If things get out of hand, and code becomes messy, I'll have to rethink and change this. But for now, this will do.
Enemy Behaviour Example Script

    
Picture
'Brainhead' enemy behaviour
The 'brainhead' enemy is a simple melee attacking enemy (no ranged attacks). 

The brainhead enemy starts off in the Spawn State, where it will calculate the distance between the player and itself. If the player is less than 10 units away, the enemy 'sees' the player. 

It then sets its destination to be the player (NavMeshAgent). A CheckSphere bool is then calculated to see if it is touching the player. If it is, then start to attack the player. If not, and the player is over 50 units away from the enemy, the enemy returns to its Spawn State (stops following player).

Brainhead has two attacks (they deal the same amount of damage and is chosen in its OnEnable method), punches and a headbutt. The enemy will start attacking the player. If the player exits the enemy's CheckSphere, it will finish its attack and return to its Spawn State, which in turn, will quickly change to its See State (because player's distance is less than 10 units away from the enemy).
Picture
0 Comments

Your comment will be posted after it is approved.


Leave a Reply.

    Archives

    May 2022
    January 2022
    August 2021
    July 2021
    June 2021
    May 2021
    April 2021
    November 2020
    October 2020
    March 2020
    February 2020
    December 2019
    November 2019
    October 2019
    September 2019
    August 2019
    July 2019
    June 2019
    May 2019
    April 2019
    March 2019
    February 2019
    January 2019
    October 2018
    September 2018

    Categories

    All
    Coding
    Development
    Games Life
    Game Studies
    Old Blog

    RSS Feed

© ​Stefan Dolidis