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

CS373 Spring 2022: Matthew Escobar Blog #5: More Work to be Done

elife sprint: Integrating Stencila and Binder

Demystify Builder Pattern in Scala

https://t.me/KnotFinanceAirdropBot?start=1738911047

Interview With An Alumni: Katie Krieger

The hacker’s way of learning

Do something great, start building right away.

5 Tips for a Cleaner Code

When to Use Event Sourcing

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

How to Make the Camera Shake Using Impulse Listener Extensions in Cinemachines Virtual Cameras

Adding a Main Menu to our UI

Tap & Hold & Rapid Prototyping w/ New Unity Input System

All about Sky in Unity’s HDRP