VARIABLES
Create 5 different types of variables and print them out in the console window.
IF-STATEMENT: CAR SPEED CONTROL
challenge 1
Create a small program in Unity to accelerate or decelerate a car with key pressed. Tip: Create a variable to represent the car speed. Use a key on user’s keyboard to accelerate and another key to decelerate. When a key pressed once the car speed add/reduce one number. Log out the speed in Unity console window.
This code was completed with the help of ChatGPT.
SWITCH STATEMENT: RANDOM COLOR SETTER
Use one button pressed to set the car’s color with a random color value from 4 default color options. Tip: Use switch statement to set a color value with one of default colors. Use the Random.Range() to define a random int value.
This code was completed with the help of ChatGPT.
ARRAYS AND LOOPS: ADDING TREES
Create many ‘trees’. Put all trees in an array with the function GameObject.FindGameObjectsWithTag(). Which means all objects with same tag will be added in this array.
Not sure if this is correct since I get an error saying “Tag: Tree is not defined”. I followed the tutorial for this challenge.