top of page

470 Blog Post 2

For this sprint I worked on a lot of the core systems for the placement and manipulation of security measures like cameras, lasers, and guards. Here's are the tasks that I completed:

​

  • As a player, I need a bounded Top-Down Camera so that I can properly see the layout of the level while playing

 â€‹

For the top down camera, I first set up a camera in the scene using Cinemachine and added a boundary box to it to keep it within a set area. I also added a post processing layer and volume component to the camera to add a vignette, bloom, and color grading effects. For the movement of the camera, I coded it with WASD controls to pan the camera, and using the mouse scroll wheel to zoom in/out. Finally, a public camSpeed variable allows us to modify the speed of the camera from the editor at will.

Top Down Camera.gif
  • As a player, I want to be able to place security measures on walls so that I can make tactical decisions to the layout of the level

Placement System.gif

This was one of the most complex mechanisms to build for this sprint, but I pulled it off without too much difficulty by utilizing a series of raycasts.

​

First, there is an invisisble box collider attached to the wall prefab which has the layer 'Placeable Area'. When a raycast from the camera to the mouse pointer's position hits this box collider, it then performs a second raycast in the direction of the wall looking for the 'Wall' layer. The hit point of this second raycast determines where the security measure will be placed.

This double raycast system works great! For cameras and lasers that is. Guards however, are placed on the ground, NOT on walls, so I added a boolean condition for each security measure to determine whether it should look to be placed on a wall or simply on the ground layer.

​

I also encountered an issue where multiple cameras or guards could be placed inside of one another, so I added an 'overlap checker' to each security measure which prevents placement if a specified box collider is overlapping with certain layers. I also wanted to make it obvious to the player what was 'place-able' and what was not, so I stored the object's original materials and set the materials to a green or red material based on whether the object can be placed or not.

​​

  • As a player, I need a money system so that I can buy the security tools I want

Money System.gif

After getting the placement system down, the money to spend on each security measure was a breeze in comparison.

​

Each security measure prefab was given a script which publicly stores the amount of money it costs. Level designers can then set this value as desired to change the cost of any security item as needed.

​

I also updated the UI of the buttons to make the costs clear for the player.

​​ 

  • As a player, I want a fog of war that makes it so that I can only see what is in front of my player or a camera I am looking in​

​

  • As a player, I need the CCTV Camera to be able to see through the fog of war so that I can look for thieves

 â€‹

I looked into a couple of different methods of implementing a fog of war system, and eventually found a tutorial series by Sebastian Lague, an excellent YouTube coder. The first video in the series can be found here: https://www.youtube.com/watch?v=rQG9aUWarwE

​

This system allows for very dynamic modification of the vision cone for guards and cameras, and also allows line of sight to be blocked by the environment.

Guard FOV.gif

​​ 

  • As a player, I need a Begin Night Watch Button so that I can start each night and play the game.​

 â€‹

Start Button and Camera FOV.gif

​​Once all of these systems were implemented, I was able to hook them together with the thief AI code from my fellow programmer, Trevor, in order to get the thieves to spawn after a button was pressed. This button also disables the UI for placing more security measures, so that nothing can be purchased or placed once the Night Watch phase begins.

​​ 

  • As a player, I need to be able to select a placed security measure so that I can make edits to it​

​​

  • As a player, I need to be able to move/ sell my security measures so that I can better optimize my layout

 

Selection System.gif

Another important aspect of the security measure system is the ability to select something that has already been placed and choose to modify it. I first created an icon that appears over an object when hovering the mouse over it, and then I created a button panel that appears after clicking the object.

​

The button panel then has buttons to sell the security measure, or to move it elsewhere using the placement system again.

This task proved to be a bit challenging, but actually worked surprisingly well right out of the gate (a rarity when programming new systems!). One issue I encountered was that the icon to select a security measure was clipping into the walls, and if moved higher then it didn't look like it was selecting the object anymore. The solution was to render the UI with a separate camera so that it always appears over the top of other geometry in the scene.

 

The final task that I worked on this sprint was:

  • As a player, I need the motion detection laser to work so that I can better look for thieves

 â€‹

This was as simple as adding a line renderer to the laser and drawing a raycast that hits walls. The same raycast can also detect if it hits the layer the thieves are on, and thus trigger some code for an alarm. Below is a gif of all of the systems that I built this sprint, including this laser alarm.

 

All Systems.gif

I'm super happy with the work that has been accomplished in the last two weeks, and I'm really looking forward to getting the core game loop done soon! Some of the tasks that I will be working on in Sprint 3 include:

      - A button when selecting a guard to begin setting patrol points

      - A button panel for changing guard movement behaviors during the Night Watch phase

      - Looking through only one camera at a time, and selecting one to activate it

      - Camera control groups to toggle multiple cameras at once

      - CCTV Network system to be able to add more active cameras at once

      - Audio Detection Sensors & Alerts

      - End of Night Watch phase scoring system

      - Tutorial System

      - Security Measure Upgrade Panel

      - Thief spotted UI Alert

​

It's a lot of work, but it'll be worth it to see the systems work together!

bottom of page