Melee Combat
The Brief
For this task I was required to implement an enemy for the player to fight. I should refine the combat actions for the player as well as implement some for the enemy itself. The enemy should be a cube, similar to that of a Slime in Minecraft, that randomly patrols a region. If the player comes within range it moves over and attacks by bumping into the player. When damaged it should break into two smaller cubes, when these cubes are damaged they should again break into two smaller ones. Some extra things I aim to achieve to make a more polished system are as follows:
- A system that allows the enemy to be broken any number of times, to satifisy a designer’s needs.
- A number of different patrolling behaviours for the enemy to add some variation during gameplay.
- Polish the combat so it is fun and challenging for the player.
- Add particle systems on impact to add polish and juice to the environment.
- Give the enemy a suitable material and animations for futher polish.
- Allow the player too wield a sword to fight the enemy.
A image of a Slime from the game: Minecraft.
Implementing behaviour for the enemy.
The enemy has two main behaviours, patrolling or engaged in combat. I will break down the functionality of each of these behaviours and how implemented them. The basic functionality of the patrolling behaviour invloves the enemy moving in an array of locations from within the world space, the designer is able to add as many locations to this array as they desire. The enemy will ‘jump’ from one location to the next whilst it’s in a patrolling state. The designer can also choose from a variety of different patrolling behaviours that I implemented, I will show the I wrote code to help visualise the method used:
Loop Once the enemy has visited each of the locations within the array, it will jump back to the first index and continue through the array until it is engaged in combat.
Reverse Once the enemy has visited each of the locations within the array, it will jump back to the previous index and reverse it’s path and continue this until it is engaged in combat.
Stop Once the enemy hasa visited each of the locations within the array, it will come to a stop and remain at that position until engaged in combat.
Unordered The enemy will jump to a location which is either one index higher or lower in the array, making it’s movement much less predictable. It will continue doing this until it is engaged in combat.
The clip below shows the Unordered patrolling bevhaviour, the time it take for the enemy to move from one location to another has been sped up for the purposes of the video. This value can be adjusted by the designer or made random between two constants.
For the enemy to become engaged in combat the player must be in a certain range specified by the designer. Once in combat it will continue to follow the player, bumping into them when they get close. Once attacked the cube breaks into two smaller instances of itself, the number of times this process happens can be adjusted by the designer. If the player escapes the enemy and distances themself far enough, the enemy will make it’s way back to the original patrol locations.
As can be seen in the video below I added to some polish to the system by giving the enemy a ‘wobble’ effect. This captures the main inspiration for this enemy which was the Slime from Minecraft. I made the player flash red to indicate when they take damage, and whenever the sword is swung game time is slowed down creating a slow motion effect.