Journal 101 — Unity 2D Mobile, Dungeon Escape Skeleton Setup

Objective: To set up the skeleton damage system

In this article, after setting up the player attack hit box collider in the previous article, we want to now add the enemy animations and behavior for when it is attacked.

We can start with setting up the animation when the skeleton is hit by the player.

We can make a transition from “Any State” to the hit animation, and use a new trigger called “Hit”.


We are going to use an interface for the damage implementation. We can use the interface type to implement common functionality.

To start, we can define a new C# script called “IDamageable”. If other classes use the interface, they must have a health get and set property, and they must have a Damage() method. So as you can see when we try to add the IDamageable interface to the Moss Giant enemy, there is an error.

We need to add the health variable and Damage method to meet the requirements of the interface.

Skeleton Damage

Now we can test the Damage() method to confirm if the player hits the skeleton. In the Attack() method, we want to check if the sword collision is with a game object that has an IDamageable interface (e.g., skeleton, moss giant, spider, box, destructible).

We can see if this works.

Skeleton Damage Implement

Now let’s update the skeleton functionality so it can take damage and be destroyed.

Damage Cooldown

When swinging the sword, the hit box may trigger multiple hits on the enemy. We can make a cooldown to only allow damage from one collision at a time.

Skeleton Damage Add Hit Animation

Now let’s add the skeleton hit animation to the behavior. We already have a reference to the Animator in the Enemy base class. We also need to pause the enemy movement between waypoints while the hit animation plays with a bool variable in the Enemy base class. We can set up a “InCombat” bool in the Animator to have the enemy switch to idle.

Before we complete this section, we need to check the distance in the Enemy base class between the enemy and the player, and keep the enemy in combat if the player is close, such as 2 units away, and if the player gets farther away, switch the enemy back to walk state.

Here are the results.

In the next article, I will go over how to create the skeleton attack so it will fight back.

Thank you for your time!




An Engineering Manager consultant who is seeking additional skills using Unity 3D for game and application development.

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

Recommended from Medium

Max area of the island: dfs and bfs approach

How to Test App Location Services for Any Place from Anywhere

dav1d 0.1.0 release: The first benchmarks

Headless vs Hybrid — Choosing an Enterprise CMS System

How I Ended up Having 25,000 Math Problems for Free — Understanding Web Scraping

Mayday Messaging is the first app using Booster

How to query a graph database — practical examples (Azure Cosmos Db Gremlin API)

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
Chris Nielsen

Chris Nielsen

An Engineering Manager consultant who is seeking additional skills using Unity 3D for game and application development.

More from Medium

Journal 142 — Unity Project Development, 2.5D Shooter

Unity Animation Event Explained

A Series On Creating Immersive Audio in Unity with Custom Wwise Scripts

Animating Zombies: Root Transforms