Creating Security Cameras in Unity

Stealth Game & Cinematography

Objective: Create a security camera behavior.

First create a script for the security camera so that we can create a behaviour for the camera

Inside the script, add a reference variable which will start a gameover cutscene when it detect the player.

Create a coroutine so that the game waits for half a second before the cutscene starts to give enough time for camera to display that it has detected the player by changing the camera ray color.

Now create a trigger enter function which detects when player enters the collider then sets the player to inactive, changes the color to red, sets all the security guards to inactive and disables the animator so that camera stops rotating.

Then add this script to the gameobject with collider inside the security camera as well as add the rigidbody component and set the trigger to true.

You can also animate the camera by rotating the value in y-axis.

Now open the animator and duplicate the animation and rename it to reverse and make transactions between them. Then change the speed value inside the reverse animation to -1.

You can then control the speed of camera rotation through samples.

And this is how it looks.




Unity Developer

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

Recommended from Medium

Why is the demand for XR engineers growing ?

About Operating System

Flash-animation in Unity3D from scratch. Part one, lyrical

RFP: How to Write a Request for Proposal for Software Development Outsourcing

DesOps : the Next Wave in Design (Part 4) The 3C’s

Fresco — Keep a lightweight app

Date command in Linux with Example

Higher-Order Functions

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
Niraj Karki

Niraj Karki

Unity Developer

More from Medium

Level Design in Unity 3D Part 6: Colliders

Building a Custom Cinemachine Virtual Camera Zoom Feature with One Button in Unity

Creating An fbx Emission Layer For Unity Using Photoshop & Blender

2D Homing Missile in Unity