Unity [Session 2]

During this session we went over the next couple sections of the Ruby's Adventure tutorial, namely 'Decorating the World', and 'World Interaction - Blocking Movement'.

The first section involved creating objects outside the confines of the tilemap that the character could move around.  The next one involved using the box collider and rigidbody 2D components to restrict the areas the player could move into.

In this exercise, the object we used was a metal box. By turning it into a prefab, we could create separate versions of the same sprite which had their own attributes.

We also implemented a very basic physics system to detect if the player colliding with the metal box and stop them from going through each other. To make this work properly and stop them jittering when making contact, we had to put in many more lines of code. I found this part of the exercise more difficult than the others, as working in code can feel pretty nebulous and I wasn't sure what exactly I was doing at times. 

Through reading the tutorial instructions on the Unity Website and listening to the tutor's explanations, it began to make more sense as the session progressed.

The last thing we did was create collectible items. This was a much more coding intensive section than the others. 

We had to put in a health system for the character to use, which could then be influenced by the item we were making. This included: max health, current health of the player when starting the game and allowing health to be either increased or decreased. Furthermore, we had to add coding to the item so that it could actually increase the health of the player.

We went on to learn how to make the item disappear when it was consumed. This was achieved  using a coding feature called a Trigger. We also had to code so that the item did not expire if the player was already at max health.  To do this, we had to add an If/then statement, which only activates an event if a specific requirement has been met. e.g. the player having less than max health.

I found this particular section quite demanding as it required both more coding and more organisation. Although initially I had some confusion, after re-reading the online tutorial, I caught up with what was happening.

This is what my Unity file looked like by the end of the session.

Comments