How to Make a Finish Line in Unity | Hackingtons

How to make a finish line in Unity

This tutorial uses Unity 2021 but can be done in any current version of Unity.

Purpose:

A finish line inidicates to the player that the level is over. They can visualize it in the scene and plan their course accordingly. The basic functionality of a finish line is to get the player to the next level.

Set up:

  1. Player is tagged as "Player"
  2. Tagged as player

    This tag will allow us to check to verify that the player was the game object that collided with the finish line.


  3. Player has a collider component, either a regular collider or a 2D collider
  4. Sphere collider component

    The collider, of any type, allows this object to read and make collisions in the scene.


  5. Player has a rigidbody component, either a regular rigidbody or a rigidbody 2D
  6. Rigidbody component

    A rigidbody is required for the game object to be part of the physics simulation, this includes collisions which are necessary for the finish line to work.

Adding the finish line object:

  1. Add a new object that will be the finish line
  2. Adding a 3D object

    This object will be our finish line so choose a shape that works well for your game. Quads and Planes are not a good choice here as their collisions can be tricky.


  3. Rename the object to finish line
  4. Renaming the finish line

    While this is not necessary for the code to work it is a good practice to get into as a game with hundreds of "cube(1)" objects is impossible to navigate quickly.