I have a grid of cubes set up from 0, 0, 0 to 11, 11, 11 and am able to move inside of the it in one unit
increments, but I am unable to figure out how to mark the individual grid cubes as occupied so I cannot place or
move a piece through those grid spaces. I have tried using a Boolean operations for occupied and placing but I
can still move through the grid space. I’m wondering if I can do this using an array, but I do not know how to
code such an array.
You could use a like then add the occupied vector to the list then compare agains the list to see if occupied…
Something like this:
//ADD THE VARIABLE
public List occupiedPositions = new List();
//when the player is on a cube add the cubes position to the list:
occupiedPositions.Add(new Vector3(cubes position));
//Then see if the position needed is occupied or not.
Eric5h5
3
I’d recommend a 3D array, so every entry in the array corresponds to a cubic unit in world space.
var world = new boolean[12, 12, 12];
world[0, 0, 0] = true;
–Eric