Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private int CoordinatesToFlatIndex(Vector2Int cellIndex, int height)
- {
- return height * cellIndex.x + cellIndex.y;
- }
- // If using width...
- // return width * cellIndex.y + cellIndex.x;
- private Vector2Int FlatIndexToCoordinates(int flatIndex, int height)
- {
- Vector2Int coordinates = new Vector2Int
- {
- x = flatIndex / height,
- y = flatIndex % height
- };
- return coordinates;
- }
- // If using width...
- /*
- Vector2Int coordinates = new Vector2Int
- {
- x = flatIndex % width,
- y = flatIndex / width
- };
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement