How To Create Security Cameras For Your Game

Games like Bioshock, Zelda: BOTW, Deus Ex: Mankind Divided, and many others have all used security cameras in some form or another. Some game object be it a robot, turret, or plain old security camera is used to detect the player and push for stealthy gameplay. Usually, the player is encouraged to avoid, destroy, or even sneak up and take control of them in some form or another. If you’ve played any of these games, then you probably know for yourself the different variations of use that they implemented these mechanics for.

To create something like this, you will need to start by creating a new object or something comparable. For prototyping/testing purposes you can just use a simple Cube and Sphere that is reshaped together so as to have a discernable front and back.

Now add a collider to your new object and adjust the collider’s position to encompass the area that your security camera can see. Make sure this collider is set as a trigger.

Next, you can animate the rotation of the camera object. This is quite simple to do. Just open up the “Animation” window in Unity and while your game object is selected, hit the “Create” button as seen in the example below.

After you create your animation you will be able to customize it within the animation window. Make sure that the “Animator” component was added to your desired game object. If not, add it and attach the new “Animator Controller” that was just created to the game object’s “Animator Component”.

[Important Note]

Make sure that you uncheck “Loop Time” for this animation from within the inspector.

Now hit the “Record” button in the Animation window and set your first keyframe by adjusting the object's rotation. This will be your camera’s starting rotation.

Next, move the “Keyframe Marker” to the time in the animation window that you want the camera to reach the end of its rotation. Then adjust your camera’s rotation to the position that you want it to end on and then stop the recording.

Now go into your object's “Animator Controller” and duplicate the animation. Then make a transition to and from this duplication and set the duplicate's speed to “-1" so that it plays backward.

By adding an “OnTriggerEnter” method to a script attached to this object you will be able to detect the Player and execute whatever effects you want!




Hi, my name is Adam Reed and I am a software engineer specializing in Unity and C# development. Feel free to scroll through and check out some of my work!

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Code Smell 50 — Object Keys

How I built My Pantry, an app to keep those veggies fresh

One week left until launch — Mintable v2.0 — Dev Update 6

Customize permissions to your API’s like a PRO

Selectors in CSS once and for all!

How to install an SSL certificate on WHM?

MicroBlog, Jekyll, MicroPub and IndieWeb

WeBlock and MixTrust Exchange have reached a strategic cooperation on liquidity investment and…

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
Adam Reed

Adam Reed

Hi, my name is Adam Reed and I am a software engineer specializing in Unity and C# development. Feel free to scroll through and check out some of my work!

More from Medium

OnCollisionEnter Vs. OnTriggerEnter — When to use them?

How to Remove a Large File from Commit History in Git?

Creating Attack Script and Collision Layers!

Variables! — The building blocks of programming