Thursday, October 29, 2020

Unity Tutorial 04

 

Once again, the Unity tutorials were met with another layer of difficulty.  A key thing that I learned about the code in our IDE is that the Update and Start are referred to as method or function interchangeably in the video (which was confusing at the start). These two functions (or methods) automatically come with each new script that is made because they are components of the  :MonoBehaviour class.

 This lesson focused on making the animals spawn automatically without the need to press the ‘S’ key. I also needed to make sure that when the food hit the animals they would disappear.

Screenshot of Unity Tutorial

In order to do this, I learned to create my own custom function. Custom functions can have any name, but it would be wiser to name it by the task the code written code is meant to perform. Otherwise it would be confusing when there are more lines of code in your script.

I also learned about the InvokeRepeating function to call our custom function. It uses the custom method name  that I added in the start. It calls that method repeatedly over a set amount of time.

Box colliders are added to any  game object we want to interact with each other. For instance, in the tutorial,  all animal objects and projectiles had a box collider on them.  The trigger would then detect objects that collide with one another depending on the size you set the box collider around the game object. Once the trigger detected the box’s space between  the pizza and the animal they were both removed.

The challenge quiz wasn’t as bad as I had initially thought. The hints were very helpful :P. Overall, it did help me refresh what I had learned. Although I was unable to complete the bonus challenge.

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