Monday, November 2, 2015

Week 6 Blogpost #5 More elaboration

For this week we are to complete our jetpack game and submit it by the end of week seven .

I was able to clean up my UI system easily once I started using it more and found it much easier to use than I did in my last post. One piece of advice I would give anyone while working with the new UI system is to keep track of what you are placing and making sure that a button is clearly named in the hierarchy or it will confuse you quite a bit.

While working on the player script I noticed that I had not added anyway for the player to get more fuel if he hit zero thus I added a method to add 1000 fuel if the fuel was == zero.
 
Some bugs i encountered were with the killZone as there was no detection that the coins prefab had collided this was solved by adding a rigidbody to the coin prefab which allowed the detection to happen .

Secondly while revisiting my previous blog post I noticed that I had not explained how the kill zone was created and will explain it in this post with exact instructions on how to make it step by step.Why was it created ? to destroy any extra game objects on the scene so it does not cause lagg over time in the user's device once it is compiled .

·      Create a cube the size of the area that you want the collision to happen in.


o   Add a box collider to the resized cube and disable its mesh renderer so the Kill Zone is invisible.

o   Create tags for the objects that are going to be destroyed .In my case I am using the tags of “Coin” and “FUEL”. Don’t forget to add a rigidbody to the game object that’s going to be destroyed in order for the collision detection to occur . Check the reference below to learn more on how to use tags .

(Unity/YouTube, 2013)       

o   Create a script that will do a collision check based on the tag .You can make a method called onCollisionEnter where you check tags to destroy the gameobject .there is a screenshot of the code below .



 Thirdly I added a simply main menu and an end game menu, which would allow the player to navigate towards the help menu or quit the game. Creating menu requires you add a canvas under the hierarchy and the canvas holds all User interface elements .For the buttons all you would have to do is right click under the canvas and go under Ui where you can select the button option but these buttons don’t have function yet so I created a script with three methods inside it and attached it to the main camera and passed the camera under on click component in the inspector after which I selected the script via the main camera and passed it the play method which has a Application.LoadLevel (“LevelName”) which as implied loads the scene you want based on its string name .Do not forget to add all scenes in the build settings or Application.LoadLevel will not work when you click the buttons .
 
Note – you don’t have to attach a script to the main camera, it can also be attached to a empty game object and that can be passed into on click and you can access the script the same way.
 
 If the "Thirdly " paragraph is too long of a read you can follow the screenshots below .








Although I have finished almost all of my requirements there are still a few things remaining to do such as to make the game more visually appealing , adding lasers as obstacles, speeding up over time and lastly adding audio .The game would need to be made as a finished game so it may be posted on our portfolios .



                                                                      References 



Unity/YouTube. (2013, April 8). Tags - Unity Official Tutorials [Video file]. Retrieved from https://www.youtube.com/watch?v=EA54-vfLkUI

No comments:

Post a Comment