Play game over scene when player is detected by cameras in Unity

Daniel Kirwan
2 min readJul 7, 2021

Objective: Run the game over scene when the player is detected

Now that the cameras are rotating (see the previous article), they need to be able to detect the player. I decided to do this with a collider on the cameras. I have a script that is on each camera that contains a reference to the game over cutscene object.

In the collision method I first need to know if the object being collided with is the player.

I am using Compare tag as it is faster than using other.tag as a comparison. I then start my coroutine that will turn the game over custscene on and it will start to play.

This will now start the cutscene and give the player the option to restart the game or quit. There are a couple of things that need to be polished up with they camera detection but that will be covered in the next article.

--

--