Now that we have the skeleton set up, let’s take a look at how we can have it so that our Spider enemy has it’s own unique methods. For this game, our spider will just sit idle in the back corner and fire off acid balls. In order to do this, we will want to go into our Spider script and remove the movement functionality, along with create a new event within the attack animation of the spider.
To do this, we are just going to create an override method within the spider script and do away with the movement:
After taking away the transition within our animator, we can see if it just sits in it’s corner:
From here, we are going to get our script set up for when our spider attacks, and after setting up the animation event within the dope sheet, we can test it out within the game:
Next, lets work on instantiating our acid balls to fire from the spider. We will need to create a couple new scripts for the attack to be used and have it linked to our spider script:
Once we get it all set up, we can test within our game to make sure that the acid balls interact with the player as well as destroy themselves after a 5 second period of time:
There we have it, we have set up our spider’s unique attack through the use of animation events. Next, we are going to explore how to create a loot system within our game.