Friday, November 27, 2020

Unity Tutorial 09

 

This week’s tutorials were a continuation of last week's sphere sumo battle game. This week's tutorial focused on spawning more waves of enemies - where when a player manages to knock out the enemy sphere from the island, an extra enemy player would spawn on the next wave. This would work the same for the power ups. By adding this functionality it will increase the difficulty of the game and keep the player engaged.

 In order to do this, we were introduced to the for-loop method. The main idea behind the for-loop method is that rather than rewriting the same instantiate code to spawn multiple enemies, adding the  for-loop to the instantiate will loop it a number amount of times depending how many enemies you want to spawn for each round.

Unfortunately, this was difficult to understand as I was not able to test out the code for myself.  My Unity kept freezing every time I pressed the play mode. Funny enough, it only happened when I added the for-loop method in my IDE (shown in green).

Screenshot of code in my IDE

If I removed this line of code by turning it into a comment, the game would not freeze when I click on Unity’s play mode. I’m not sure why this is the case but I wasn’t really able to properly follow along and see if the code I put in the script actually works.



Here’s a screenshot of my frozen Unity. No pretty cloud particles in the background and no enemies spawning. 


For Challenge 4, I made a separate project as I was worried that it would freeze too and I  didn’t want to take any chances. I found this challenge the most difficult; not only because it was challenge 4 but I couldn’t look back at the code on  the Sumo battle project so I had to review it from the tutorial page.

Again, my biggest problem for this challenge was not being able to spawn extra enemies in every wave. I fiddled with the code here and there but couldn’t work out what I was missing. The thing I learned from programming a game is that you need a lot of patience and accept that sometimes it will be more mistakes than progress. I will try again with a clear mind and hope for the best.


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,...