Adding Animations
|
This week most of my time was spent on adding animations to the different enemy types as well as the Behemoth Cannon to give the game more life and to also give some visual feedback to the player when he does certain actions or when certain things happen on screen. In order to add an animation, I first get a sprite sheet from my artists that has each frame of that animation in an equally sized cell, I then use the Unity sprite editor to slice that sprite sheet into the separate frames based on the cell size, note that you need to select the “Multiple” option for “Sprite Mode”. I slice the sprite sheet based on cell size instead of using the automatic function because it works better for sprites that are not one single avatar. After that I drag the sliced sprite sheet into the game scene to create the animation. After that I add an Animator component to the game object I want to animate, and give it an Animation Controller where I create transitions between the different animations using various triggers.
One thing I had trouble with in the beginning was how to trigger functions on specific frames, I started hard coding timings at first, but then realized that when using the “Animation” window in Unity I could add things called “Animation Events” to a specific frame which then allowed me to call a function from any of the scripts attached to the same game object. As you can see above, the Enemy Spawner, creates an Enemy Drone when the door is fully open, and this was done by the method I just mentioned. Adding some of these animations did cause a bit of a problem for my fellow coder and I since they forced us to make some drastic changes to some of the scripts we have already worked on. In some way this led to cleaner code, but it was also work we did not think would require so much work, but all in all we are happy with the results, and most of the timings we had to keep track of are not needed anymore because the “Animation Events” allowed us to pinpoint the exact frame we wanted something to triggered or called.
|


