public Exit[] exitArray; //In the order 0 = South, 1 = West, 2 = North, 3 = East private int GetExitIndex(Exit exit) { for (int i = 0; i < exitArray.Length; i++) { if (exit.Equals(exitArray[i])) { return(i); } } Debug.LogWarning("GetExitIndex could not find exit in exitArray"); return(-1); }