Quantcast
Channel: Questions in topic: "adjacent"
Viewing all articles
Browse latest Browse all 40

How would I find neighbours of a tile in a grid ?

$
0
0
Hello everyone, I am currently trying to create a small builder game. So I have arrived at a massive problem. SOLUTION CAN BE FOUND HERE !!! [https://github.com/FilipStudeny/Cellular-Automata---Island-generation][1] ---------- I can generate a grid that is made out of cubes each cube has its own script (Tile.cs) and that script holds references to its four neighbours (Above,Right,Left,Bellow), however I have a problem figuring out how to add these neighbours to the tiles. ---------- I don't want to use Raycast or Sphere for neighbour detection as it slows down performance. ---------- This is my code for the grid generation. public class WorldGenerator : MonoBehaviour { public int mapSize; public GameObject tile; public List tiles; // Start is called before the first frame update void Start() { GenerateStartingGrid(); AssignTileNeighbors(); } void GenerateStartingGrid() { for (int x = 0; x = 0) { } //Right neighbor if (x + 1 = 0) { } //Above neighbor if (y + 1

Viewing all articles
Browse latest Browse all 40

Latest Images

Trending Articles





Latest Images