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.




Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

My Experience of becoming a Tezos Baker

Remove comments from your SQL Server T-SQL query

My 2¢ on scoping in CSS

Celebrating the 4th year of the Learn Scientific Programming Initiative!

Design Blog 2: Identicons

Designing Online Game (System Design)

Big O Notation: A Guide for Beginner Developers

How to make Token-Based Auth Rest API using Django rest framework

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Gabe Gomez

Gabe Gomez

More from Medium

Platformer: Player Animation Part 1

Creating a UI Shield Strength indicator

Transposer Virtual Camera Explained in Unity’s Cinemachine

Pushing Objects in Unity to Complete Puzzles