Monday, November 30, 2015

Week 10 -raycasting and a health bar !

For this week we learnt about how to use ray casting which as the name indicates is simply a ray being cast against all the colliders within the scene.

Although I initially found using ray casting slightly challenging reading up on the unity documentation helped and thus I am referencing them below although I have to find a way to use it in my current project, maybe to place the torrents? (Unity, n.d.).

While working on the game itself I found it difficult to make a health bar thus I asked for help to one of my peers who recommended that I use a tutorial video on how to create a health bar in unity using the UI canvas and a few colors.

In order the make the health bar you would first need to create a canvas and change its render mode to world space in order to resize it and make it small enough to only hold the health bar after which you can add a green colored image to it looks like a health bar, in order to give mine a more realistic feel I first added a black background then resized two colored images to fit inside it.














In order to show that the health is decreasing you will need to make a script to change its scale so It would appear as the health was decreasing .The code is very simple thus I am only placing a screenshot of it .(XOctoManx/Youtube, 2015)




























References
Unity. (n.d.). Unity - Scripting API:. Retrieved from http://docs.unity3d.com/ScriptReference/Physics.Raycast.html

XOctoManx/Youtube. (2015, May 2). Unity 5 Tutorial: Easy Health Bar C# - using localScale [Video file]. Retrieved from https://www.youtube.com/watch?v=87R0PziLDJ0&app=desktop


No comments:

Post a Comment