Lynda.com: Become a Unity 2D Developer (Day 12, Completion)

More Enemies

Aliens that Attack

For this exercise, I once again had to create a game object using specified frames and assigning values accordingly.  Ultimately, I created another alien enemy using frames 1 - 10 for an idle animation.  From there, I created an additional animation based on the frames 11- 16 for an attack animation.  Lastly, I placed the new Alien enemy onto the stage and tested it.  Although the animations worked by manually adjusting the values, it was now time to add code to automate the animations.


I then applied this script onto the alien in order to trigger the new attack animation.  At this time, the code and the trigger function is working as designed.



**Note, there appears to be some sort of transparency issue with the Alien, but the code is working as intended.**

Animation-based Attack Trigger

In order to ensure that the alien attack will trigger the correct animations for the alien and the astronaut, I had to incorporate more C# code to the alien and the explode function.  Below are the two modified scripts that allow the astronaut to not only trigger the animations, but explode on contact with the alien enemy.






Aliens that Shoot Projectiles
Getting this new alien to simply render was a hassle.  At first, the code and animation would not execute regardless if I followed everything within the tutorial.  Nevertheless, it was a matter of ensuring that the required semi-colons were put into place at the end of each statement.  It was an honest rookie mistake that took over 15 minutes to resolve.  I guess that comes with the territory.  Nevertheless, below is the code I have implemented onto AlienC.  Ultimately, this sets up AlienC with a shooting animation when the Astronaut is near.



Alien Projectile Simple
Although I was able to successfully apply the C# code and setup the animation layers, it is not rendering the Alienspit animation correctly.  However, the scripts are working because there is a bit of a green render at the beginning of the animation.  Nevertheless, I am moving forward.  Below is the code and the current animation that is triggering every 3 seconds.



UI
Create an Air Meter
This exercise was not too difficult, but heavily GUI based.  Nevertheless, after following the instructions, I was able to implement an Air Meter for the player.  The meter is located on the top left of the video game interface.  Also, this corrected the rendering issue with the Alienspit.  It is now working and causes the astronaut to explode on impact.

Wire Up the Air Meter 
The last and final step to the 2D project is to implement some code to the Air Meter.  At this time, it is rendering the meter, but has no direct impact in regards to the Astronaut's actions.  Ideally, the air meter will be based on time, but once it runs out the player will explode.  This new mechanic will ultimately create another inherit obstacle for the player, specifically time.  If the player does not reach the end before the air meter is exhausted, the player simply loses by default.  In this case, the player will explode if the goal is not reached in time.


Now that the air meter is working, it is time to finish off the project.  First, I needed to remove the GameStaging scene and replace it with LevelDesignStaging.  This was accomplished with the File -> Build Settings menu.  Next, I had to modify SplashScene to incorporate LevelDesignStaging within the "Click to Continue (Script)".  Ultimately, when the game loads, the splash screen informs the player to click on the screen and it will load the game instantly.

Final Thoughts
This entire experience has been quite educational.  Spending hours on and off the learning project has definitely shown me how easy it is to get in the zone and way off course.  Unsurprisingly, taking some time off of the game project set me back not only production wise, but mentally.  I had to take some time to reacquaint with the GUI and keyboard commands.  Needless to say, I had a wonderful experience learning about C# and building game objects.  Unity is a very powerful platform, especially when it comes to availability for numerous platforms (PC, MAC, Android, etc.).  I look forward to creating a custom game based on what I have learned here.  Not sure when I will be creating a Unity game, but I will be sure to blog about it at some point.  For now, I hope you all enjoyed this learning experience as much as I did.  As for now, I am moving on to another technology to study.

Comments

Popular posts from this blog

JavaScript 30: JavaScript Drum Kit

Lynda.com: Become a Unity 2D Developer (Day 11..Sort of)

Back On the Coding Horse