Adding the final enemy, the Skeleton
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.
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.
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.
Since the skeleton script is going to inheriting from the Parent Enemy script, we basically have everything we need without adding anything new.
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.