Sunday, February 21, 2021

Unity Tutorial 03

  

Unity tutorial for week 4 was quite script-heavy.  The information and explanations that came along with the instructions was a lot to digest. So far, I think this may have been a more challenging unity session for me.

The first part of the tutorial we were introduced to the ‘trigger’ element in games. This was something which we also briefly covered in last semester. They are similar to colliders except instead of blocking movement, Unity’s physics system will only tell us if a game object collided with it. For this part, we applied the trigger on the collectable strawberry, which restores health when Ruby picks it up.  In the game console, it will tell us how much health Ruby has restored. Looking back, if I was aware of this part the tutorial it would have been a neat mechanic to have for my game in semester 1.

For the second part of the tutorial, we had to write a script with the same trigger to restoring health but for the damage zone (spikes) in the map. The only difference is that if Ruby collides with spikes, they will not disappear but instead inflict damage. We also added an enemy robot to the scene which walks back and forth which runs on a timer before it changes direction. When it collides with Ruby, it inflicts damage. However, instead of using the trigger function, we used OnCollsionEnter2D that is linked with the enemy’s Rigidbody component – since the enemy is a solid object compared to the health buff it needs to interact with the player.

 Here is a screenshot of my progress so far. As mentioned in the previous Unity post I did end up changing the game objects and background a bit.  











No comments:

Post a Comment

Doing

  We are nearing the end of this semester and the book we’ve been working throughout the semester is in its final editing stages. This week,...