Hi all,
I am having a problem with obstacle detection on my grid. My grid size differs depending on the current level of the game. Currently my grid is instantiated piece by piece and placed inside a List<>. Attached to the grid pieces is this class:
public class gridtile : MonoBehaviour
{
// This class will be used so we can modify the isOccupied flag
// if the grid section is occupied, the cube cant move onto it
public bool isOccupied = false;
public bool haslightsOn = false;
public gridtile north;
public gridtile south;
public gridtile east;
public gridtile west;
}
Once the obstacles have spawned on a part of the grid the isOccupied flag changes from false to true. I am trying to figure out how to initialize the north, south etc pieces dependant on the current tile my player is on. I think this sort of looks like a linked list. My player object moves from grid piece to grid piece. The player class also has a data member called gridtile currentTile.
I am not sure also how to “read ahead” in the list so that for example this code may work:
if (currentTile.north.isOccupied)
{
canMoveNorth = false;
}