I’m in a programming class and we need to do some AI work this week. The basis of the assignment is to have multiple rooms with “Guards” and control them using specific key commands. We have an object that will navigate the rooms, but if detected my a guard, will restart. I’m still new-ish to programming, so some of these things don’t make sense to me. Here’s the starting of my scripting. When the arrow keys are hit we are supposed to scroll through each guard in the scene and be able to control their movements to have them avoid the player.
using UnityEngine;
using System.Collections;
public class DebugManager : MonoBehaviour {
public GuardData[] guards;
GuardStateMachine gsm;
private GameObject theGuards;
// Use this for initialization
void Start () {
guards = GameObject.FindObjectsOfType<GuardData>();
gsm = GetComponent<GuardStateMachine>();
}
// Update is called once per frame
void Update () {
if (Input.GetKey(KeyCode.RightArrow) || Input.GetKey(KeyCode.LeftArrow))
{
for (int i = 1; i < guards.Length; i++)
{
Debug.Log("Input");
theGuards = GameObject.FindGameObjectWithTag("Guard");
theGuards.renderer.material.color = Color.blue;
}
if (Input.GetKey(KeyCode.Alpha1))
{
}
if (Input.GetKey(KeyCode.Alpha2))
{
}
if (Input.GetKey(KeyCode.Alpha3))
{
}
if (Input.GetKey (KeyCode.Alpha4))
{
}
}
}
}
Thank you guys for any help offered.