Security camera.

Hello folks!!

Here is my idea:

Player enter in a security camera’s field of view… The light projected by the camera turn yellow… After 2 second, while player is inside the camera’s fov, the light turn red… When the player is not on camera’s fov, a cool down time is active… After the cool down, the light turn white and camera back to default behavior.

I use OnTriggerStay with a Raycast spotting the player and OnTriggerExit to start the cool down.

Any idea how?

Hey Goodmorning (well morning for you atleast),

You can something like this for the cooldown:

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour {

	private bool inside = false;
	public float cooldown;

	void OnTriggerEnter (Collider other){
		if (!inside) {
			if(other.tag.Equals ("Player")){
				inside = true;

	void OnTriggerExit (Collider other){
		if (other.tag.Equals ("Player")) {

	IEnumerator Cooldown(){
		yield return new WaitForSeconds (cooldown);
		inside = false;

You can set the seconds of the cooldown in your Inspector. you can also change “cooldown” for 1.0f orsomething. In the IEnumerator.