Skeleton Enemy — Dungeon Escape

Going over my implementation of my Skeleton Enemy in Unity

Objective: Walkthrough my implementation of my Skeleton enemy for my mobile game, Dungeon Escape.

Code Optimization

Before starting on my Skeleton enemy, the first thing I did was optimize my Enemy C# script. The reason I did this is that the movement behavior for my enemies is pretty similar, so it only made sense to further optimize my script to handle this. With the changes I made, I was able to move all code for both my Spider and Moss Giant enemies into the parent class. The Skeleton enemy will also be able to make use of this. The code I refactored is shown below.

Doing this allowed me to have empty scripts for my Moss Giant and Spider enemies as they inherit all of this code from the Enemy parent class.

Example of empty class that still works in-game due to inheritance

As can be seen, the Moss Giant enemy still properly performs their actions (the same goes for the Spider enemy as well).


With these changes now in place, we can go ahead and start creating the animations for our Skeleton enemy. Just like I had done for my Spider and Moss Giant enemy, I will be creating the idle and walking animations for now. Once implemented, the below gifs demonstrate how our Skeleton enemy looks.

Idle Animation
Walk Animation

Lastly, I hooked up my animations in the Animator Tree to prepare the animations to be controlled with code.


Now since we had optimized our code earlier, we can leave the Skeleton enemy class empty, and it will still work so long as we are properly inheriting from the Enemy parent class.

The result of this setup is shown below:

That is all for today’s article! Thank you for taking the time to read. In the next article, I will begin creating the attack system for the game.