• About
  • 2D Car Unity Game
  • Date: 08/03/2020
  • Class: MAC280-Game Programming
  • Software: Adobe Photoshop & Unity
  • Video: https://www.youtube.com/watch?v=bQaRM8T2AGE
  • Game Concept
  • In my game, when the player's car hits another car, they will exit the game. If the player's car avoids other cars and survives for a certain time, the player will earn points. The background will automatically move, creating the illusion that the player’s car is driving on the road.

  • Steps
  • Design Elements:
  • Design the game cover, buttons, and background in Photoshop. Find car images online.

  • Scenes:
  • Menu Scene:
  • Contains a button to navigate to the car selection scene.
  • Background music is added.
  • The button uses a script to handle clicks and transition to the next scene.

  • Car Selection Scene:
  • Contains a button to start the game.
  • Background music is added.
  • The button uses a script to handle clicks and transition to the playing scene.

  • Playing Scene:
  • The background uses a quad game object with a script for vertical sliding, creating a repeating effect.

  • Player Car
  • CarController Script:
  • Controls the player's car speed, direction, and maximum position.
  • Uses Rigidbody 2D and Box Collider 2D to prevent the car from passing through enemy cars.
  • Includes background music that plays during the game.

  • Enemy Cars
  • Prefabs:
  • Enemy cars are prefab objects.

  • Enemy Car Move Script:
  • Sets speed, direction, and maximum position.
    Uses Rigidbody 2D and Box Collider 2D to prevent passing through the player's car.

  • CarSpawnPosition GameObject:
  • Randomly spawns enemy cars.

  • Car Spawn Script:
  • Manages vehicle sequence, maximum position, and spawn delay.

  • Destroyer GameObject:
  • Uses an enemy destroyer script to remove enemy cars from view.
    Uses Rigidbody 2D and Box Collider 2D to resize the destroyer range.

  • Buttons
  • UI Buttons (Stop, Play, Menu, Exit):
    Add background images to the buttons.

    ButtonMenu Script:
    Handles clicks to navigate back to the menu, stop the game, replay the game, or exit the game.
    Buttons appear after the game is over.

  • Score
  • UIManager Script:
  • Increments the score by 1 point for every 3 seconds the player’s car survives.
    Displays play, menu, and exit buttons after the game ends.
    Stops the score from increasing when the game is over.