Unity Tutorial 6

 Unity Tutorial 6


For this week's tutorials, I learned how to repeat my background. I began by making a new script. I attached it to my background object by dragging it to the inspection side. Next, I had to redo the background in order to create the illusion of an infinite road. I did this by making a new variable and assigning it a transform. positon. Then with a box collider, I made the loop created in the script look seamless.

Unity
Then I had to make a game over trigger which I had never made before. I added a ground tag to the ground. I added a tag obstacle tag into the obstacle prefab. In player control, I made a game-over variable. I changed the code to have an if-statement to show if the player collided with the obstacle the game would be over

Then by making a new script I made the background stop once it triggers the game over. I made a new private player controller script. Then I wrapped the translate method in an if-statement. Then I stopped the obstacle from spawning. Lastly, I added an if-statement to destroy any obstacles
that exit the bounds of the screen.

Comments