Skeleton Enemy

Adding the final enemy, the Skeleton

Simon Truong
3 min readDec 4, 2021

--

Using what we have learnt with the Moss Giant and Giant Spider, we now understand how the Abstract classes work and how class inheritance work. It is much easier to create and add new enemies now due to the class inheritances passing on data in the clean and control manner.

Prepping the Skeleton:

Similar to how to we have done so with the Moss Giant and Spider, we will now proceed to add the Skeleton Enemy using the same method.

Slice the animation sheet and import the first frame into the scene. Then create an empty game object to house the sprite.

Make sure to zero out the X & Y position so both the parent object and sprite object match.

Once you have set up the parent and child objects, in the Animation window, click “Create New Animation” button to start animating. We are going to do the two default animations “Idle and Walk”.

In the Animator window make sure to add the Idle Trigger as the parameter. During the transition between Walking > Idle, we will need to add the trigger as our condition.

Make sure that the Duration is Zero and we have no “Exit Time”.

Remember to name the Idle animation “Idle” to keep the uniformity and so the Enemy script can identify the correct animation state.

Before we setup the scripts we are going to make 2 new waypoints that the skeleton can travel to.

Skeleton Script:

Since the skeleton script is going to inheriting from the Parent Enemy script, we basically have everything we need without adding anything new.

As always, it is best practice to place the override Init method in every new enemy script.

Back in Unity, drag in the two new transform waypoints into the script slots for “point A” and “point B”.

With just the override Init method on the Skeleton Script, it can already move and pause accordingly. This is the beauty of using Class Inheritance within Unity.

--

--

Simon Truong

A Designer, an Illustrator and a massive tech geek aspiring to become a professional Unity Developer.