Security Cameras in Unity

Valdarix Games
3 min readMay 16, 2021

Simple cameras to detect the player.

The camera in action

Yesterday we gave our guards the ability to see the player using a box collider. Today we will setup some security cameras that will detect the player and trigger the same game over scenario.

The cameras are a little more complex than the guards. Guards see directly in front of them, while the cameras need to rotate and have a cone shaped line of sight.

We will still use a collider for this but a box collider won’t be the best option. Instead we will use a different type of collider that we can conform to the shape of our camera cone.

My camera has 3 parts. The camera cone, the camera itself and the holder. The holder won’t be touched once we set everything in place, but we will work with the camera and the cone.

The first part of our camera, the one that will do the work is the camera cone. The cone will be what detects our player when he enters into the light. Now we could use a sphere collider if we really wanted to but why do that when Unity gives us something as good as the Mesh Collider.

The mesh collider will conform to the object we placed it on as long as we choose to make it convex. We want to minimize the number of mesh colliders we use in our games. If we have a lot of really complex meshes and we apply mesh colliders to…

--

--

Valdarix Games
Valdarix Games

Written by Valdarix Games

Turning my passion for video games and software development experience into a focus on video game development.