Journal 72 — Unity’s “The Great Fleece”, Add Security Cameras

Chris Nielsen
4 min readAug 18, 2021

--

Objective: Animate and add detection to security cameras

In “The Great Fleece”, we completed the coin distraction to help Darren sneak past the guards. Now we want to animate and turn on detection using the security cameras.

If you look at the security cameras, we want to make a simple animation that modifies the y-rotation from +45 to -45 degrees.

To do this, we can select the camera game object and select Create Animation in the Animation window.

From there, we can select record and fix the first y-rotation, then move the time 1 second and enter the second y-rotation, and stop recording.

Here are the results.

Now we can modify the Animator component to reverse the camera movement.

We need to first turn off loop time.

In the Animator window, let’s duplicate the security camera movement, and create transitions between both.

We can change the duplicated camera movement to make it reverse by setting the speed to -1.

In Unity 2021, we need to reduce the speed on the forward and reverse animations. I tried 0.1 and -0.1.

Here are the results.

To add a trigger to the security cameras, let’s create a new C# script and attach to each camera cone game object, make sure the mesh collider has trigger set, and that each camera cone has a Rigidbody component. In addition we want to add a reference to the game over cutscene on each camera cone.

Here are the results.

As you can see in the ending cutscene, our player Darren is still visible walking through the cutscene. We can fix that by making sure he is inactive in the cutscene.

Go back and turn on the game over cutscene and open up Timeline. We need to add a new “Activation Track”, and drag in the Player game object, and reduce its duration to one frame, and move it to the very end of the clip.

Let’s see the results.

Two other items to clean up are to add a freeze effect on the camera, and also change the camera color from green to a red tint.

In our security camera script we can create a reference to the camera game object Animator component, and get a reference to the Mesh Renderer. When the camera cone is triggered, we can set the enabled animation to false. We can also use a coroutine to delay the game over cutscene slightly so we can see the camera effects.

Now let’s see the results.

Thank you for your time!

--

--

Chris Nielsen
Chris Nielsen

Written by Chris Nielsen

An Engineering Manager consultant who is seeking additional skills using Unity 3D for game and application development.

No responses yet