In my script, I have an array of “guard” objects that is populated by all objects that is a “guard” object. I need to be able to select a specific guard in that array, visually represented by the guard changing color, by cycling through the array with the left and right arrow buttons. I’m really bad at arrays and I’m not sure at all how to go about this, so I’m hoping someone can reach out and lend me a hand.
Guard[] myGuardArray;
Guard guardRef;
// Use this for initialization
void Start ()
{
myGuardArray = FindObjectsOfType<Guard>();
}
// Update is called once per frame
void Update ()
{
if(Input.GetKeyDown(KeyCode.LeftArrow))
{
//what to put here?
}
else if(Input.GetKeyDown(KeyCode.RightArrow))
{
//what to put here?
}
}