Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
AI Group Manager
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class EnemyManager : MonoBehaviour {
public Vector3 playerLocationSeen;
public Slider timerSlider;
private Animator timerAnimator;
private Image timerFill;
public bool alerting;
public bool alert;
public float currentAlertTime;
public float alertTime = 15;
public bool canSeePlayer;
private bool timerSliderPopUp;
private AudioSource alertSound;
void Start()
currentAlertTime = alertTime;
timerAnimator = timerSlider.gameObject.GetComponent<Animator>();
timerFill = timerSlider.GetComponentInChildren<Image>();
timerSlider.maxValue = alertTime;
timerSlider.value = alertTime;
alertSound = GetComponent<AudioSource>();
void Update ()
alerting = false;
if (alert)
if (!timerSliderPopUp)
timerSliderPopUp = true;
currentAlertTime -= Time.deltaTime;
timerSlider.value = currentAlertTime;
if (currentAlertTime <= 0)
currentAlertTime = alertTime;
alert = false;
timerSliderPopUp = false;
canSeePlayer = false;
timerFill.enabled = alert;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.