void CreateCollision(int y) { YLevels lvl = yLevels[y]; GameObject go = new GameObject(); BoxCollider box = go.AddComponent <BoxCollider>(); box.size = new Vector3(sizeX * scaleXZ + (scaleXZ * 2), 0.2f, sizeZ * scaleXZ + (scaleXZ * 2)); box.transform.position = new Vector3((sizeX * scaleXZ) * 0.5f - (scaleXZ * .5f), y * scaleY, (sizeZ * scaleXZ) * .5f - (scaleXZ * .5f)); lvl.collisionObj = go; lvl.collisionObj.name = " lvl " + y + " collision"; }
void CreateGrid() { grid = new Node[sizeX, sizeY, sizeZ]; for (int y = 0; y < sizeY; y++) { YLevels ylvl = new YLevels(); ylvl.nodeParent = new GameObject(); ylvl.nodeParent.name = "level " + y.ToString(); ylvl.y = y; yLevels.Add(ylvl); CreateCollision(y); for (int x = 0; x < sizeX; x++) { for (int z = 0; z < sizeZ; z++) { Node node = new Node(); node.X = x; node.Y = y; node.Z = z; node.ChangeNodeStatus(true, this); if (debugNode) { Vector3 targetPos = GetWorldCoordinatesFromNode(x, y, z); GameObject go = Instantiate(debugNodeObject, targetPos, Quaternion.identity) as GameObject; go.transform.parent = ylvl.nodeParent.transform; go.SetActive(true); node.worldGameObjet = go; } grid[x, y, z] = node; } } } }