Building A Stealth Game — Creating Security Cameras

Photo by Pixabay from Pexels

Getting a better cone of vision

The first thing we’ll do to iterate upon the security guard is upgrade our “vision” collider. With the guard, we could only create a collider out of simple 3d shapes such as boxes and cylinders. With the security camera, we’re going to make use of the Mesh Collider because we have a mesh asset available to us.

Mesh Collider component in the Inspector.

A visual cue for the player

Another improvement we can make to our game is to make things a bit clearer for our players by making the camera’s vision cone visible.

The security camera’s vision cone is visible but not opaque.

How does the camera move?

In a previous article, we had learned about using Unity’s navigation features to move AI security guards. We want our security cameras to move too, but not in the same way. We want them to remain in place while rotating back and forth on a limited angle. For this we will use the Unity animation system.

The Animation window for an object that doesn’t have an Animator component.
The Animation window for a new animation. The “record” button is the red circle in the upper left.
The security camera animation in the Inspector window.
The security camera animator controller in the Animator window.
The security camera animator controller set up to transition between the forward and reverse rotations.


And that covers it. Much like with the guard, how the security camera should react now when the player is spotted is up to us to figure out, but I hope this article was helpful in exploring how a security camera could be formulated in Unity. Thanks for reading.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store