Screenshot of my progress in Unity - RIP Jambi |
For this week’s Unity tutorials we were introduced to adding a User Interface or UI in the game. It was our first time covering this part of game creation, so it was fun first part of the tutorial. To include a UI in our game we added a Canvas game component to our hierarchy. Another game object was automatically imported called EventSystem that focused on how the player would interact with the UI. However we didn’t work with this for this part of the tutorial.
The Rect Transform component had various
screen settings for how the UI should be displayed in the player’s screen. For this tutorial, we left it at the default
option – screen space overlay which essentially renders the UI above all the other
game objects making it easier to see.
We were
also introduced to static members to easily call our UI script without the need
to reference which makes the process much simpler as we only need to include
the keyword ‘static’ in the UI HealthBar instance and using that bit of code
will let us access that property anywhere in our scripts.
The next
tutorial was still linked to UI. We
included a friendly frog NPC, Jambi, where a dialog box would appear when the
player presses the ‘X’ key to ‘ talk’ to Jambi. This works using a feature in
Unity’s physics system known as raycasting. The code for the raycast was put on
Ruby, once the player presses the ‘X’
key, a ray is cast from Ruby a certain
distance. If that ray detects the collider of another game object, like Jambi, then
the dialog box will appear.
Unfortunately, Jambi ghosted me when working
on my tutorial. He was invisible but the dialog box would still appear and I could
see his bounding box when I click on it. I tried to fix the issue with the sorting
layers but it didn’t seem to work. Hopefully he’ll make an appearance before
the end of the tutorials. 😜
No comments:
Post a Comment