EX7 - Combat


In the final exercise for this module, we have been asked to implement combat; to add an enemy slime who splits into smaller slimes on death, who tracks the player and bounces back when hit or when it hits the player.

Started off creating a minecraft inspired slime and 2 spheres on the sides of it.

The spheres represent the spawn point of the smaller slimes when the bigger one is killed. 

After this i added a navmesh agent in which the slime has a variety of movement modifiers, obstacle avoidance and pathfinding.


Nav mesh agents only work on terrain in which a nav mesh is baked into it, so i made a platform and baked the navmesh which turns blue, showing the moveable area.

When the player is on this platform and within a certain defined range of the enemy, the enemy becomes active and follows the player. if the player touches the enemy with the combat hand, the enemy will take one point of damage and go back. If the enemy touches the players hitbox, the player recieves one damage and the slime bounces back. This is to reset the colliders otherwise the slime wouldnt be able to damage the player again as hes already within the collider. The health and damage values can be modified

The slime cannot exit the platform or be knocked off of it. 

https://i.gyazo.com/443a4e7ee22a796dacb8abb0dae0ab11.mp4

If the player loses all of his life, then he dies and is respawned at the designated respawn cube

Because i dont have a complex combo system inplace, if you keep pressing the attack button, the character becomes stuck in the animation is frozen until you stop pressing it. this can be annoying in situations when you want to secure the attack but you cant spam it otherwise you will get hit. The player can also move whilst punching because otherwise its going to be annoying having to interupt movement to attack.