I'm trying to use a loop to place my player in the seat that is empty which works fine but I'm trying to set a bool to false when the player leaves it but I can't seem to get access to it
IndexOutOfRangeException: Array index is out of range. GetIn.ExitObject () (at Assets/GetIn.cs:118) GetIn.Update () (at Assets/GetIn.cs:55)
public int whatSeat;
Transform TheObject;
positions = TheObject.GetComponent<GetInObject>().PosInObect;
for (whatSeat = 0; whatSeat < positions.Length; whatSeat++)
{
if (positions[whatSeat].isOccupied == false)
{
transform.parent = positions[whatSeat].pos;
positions[whatSeat].isOccupied = true;
}
}
and then in another function I want to access the same whatSeat
variable to turn it to false when you exit
positions[whatSeat].isOccupied = false;
but that is where the error crops up I don't know how to solve this