private void GenerateTree(Vector3 [] verts, int v) { GameObject getTerrainTrees = TerrainPool.getTrees(); if (getTerrainTrees != null && world.treeDensity != 0) { Vector3 treePos = new Vector3(verts [v].x + this.transform.position.x, verts [v].y + this.transform.position.y, verts [v].z + this.transform.position.z); getTerrainTrees.transform.position = treePos; getTerrainTrees.SetActive(true); getTerrainTrees.transform.SetParent(terrainHolder); treeCollection.Add(getTerrainTrees); } }
private void GenerateRock(Vector3 [] verts, int v) { GameObject getTerrainRocks = TerrainPool.getRocks(); if (getTerrainRocks != null && world.rockDensity != 0) { Vector3 rockPos = new Vector3(verts [v].x + this.transform.position.x, verts [v].y + this.transform.position.y, verts [v].z + this.transform.position.z); getTerrainRocks.transform.position = rockPos; getTerrainRocks.SetActive(true); getTerrainRocks.transform.SetParent(terrainHolder); rockCollection.Add(getTerrainRocks); } }
private void Start() { instance = this; pool = new List <GameObject>(terrainPoolSize); currentPosition = Vector3.zero; var range = CreateTerrains(0, startGrassCount - countToSeePlayer, false); pool.AddRange(range); range = CreateTerrains(0, countToSeePlayer, true); pool.AddRange(range); while (pool.Count < terrainPoolSize) { AddTerrains(); } currentPosition.x = terrainPoolSize; }