Unity notes

This is a gathering of notes that I took for different kinds of games, such as things to keep in mind.


A platformer is a game such as Super Mario Bros, in which a player is jumping/climbing between platforms, to reach a goal.

We are considering that you are in Unity 3D, without the Z-axis.

  • πŸ“˜: Add a RigidBody to the player
    • πŸ“˜: To move the player, use forces (up=jump, left/right=move)
    • πŸ“•: Fix the rotation (X, Y, Z) => prevent unexpected rotation
      • if you can't freeze the rotation, you can create an empty game object. Using a script, update the empty game object to match the player transform. Then, simply place the camera in the empty game object.
    • πŸ“•: Fix the position (Z) => won't fall
    • πŸ“•: Remove frictions => otherwise, the player can stay in the air, by clamping a block
  • πŸ“˜: you may nest the camera inside the player, to make the camera follow the player. You can tweak the Z-axis to move the camera near or far from the player.
  • πŸ“˜: to check if the player is on the ground, you can check if the player is colliding with the ground
    • πŸ“•: if you are using OnColliderEnter/OnTriggerEnter, beware of a bug when you are both exiting and entering a new block


This game is called casse-briques in French. "In Breakout, a layer of bricks lines the top third of the screen, and the goal is to destroy them all by repeatedly bouncing a ball off a paddle into them." (Wikipedia)

We are considering that you are in Unity 3D, without the Z-axis.

  • πŸ“˜: Create 3 walls (left, up, right) with a collider
  • πŸ“˜: Create a paddle (ex: flat cube) with a collider and a rigid body
    • πŸ“•: freeze Z-axis
    • πŸ“•: freeze rotation (X, Y, Z)
    • πŸ“˜: move the platform by checking the position X of the mouse
      • πŸ—’: you may use Camera.ScreenToWorldPoint
  • πŸ“˜: Create a ball (ex: sphere) with a collider and a rigid body
    • πŸ—’: make the ball interpolate (smooth collision)
    • πŸ“•: freeze Z-axis
    • πŸ“˜: make the ball bounce when colliding
      • πŸ—’: using Vector3.Reflect
    • πŸ“˜: destroy the ball when lost
      • πŸ—’: check if renderer is visible
  • πŸ—’: Set the camera mode to orthographic
  • πŸ“˜: Create a brick (ex: flat cube) with a collider
    • πŸ“˜: the brick should be destroyed after X hits
    • πŸ—’: change color when hit, revert back after X seconds
    • πŸ—’: add indestructible bricks
  • πŸ“˜: Create a level using bricks
  • πŸ—’: Game Manager
    • πŸ—’: handle points
    • πŸ—’: handle lives
    • πŸ—’: handle levels
    • πŸ—’: create the ball and the paddle
  • πŸ—’: add menus
    • πŸ—’: state machine (Play, GameOver, LevelCompleted, etc.)
    • πŸ—’: update the UI in the setter of points/lives/levels