//Spawning of the goldmine and turret public void SpawnBuilding(int unit, float yCount) { Vector3 clickPoint = Vector3.zero; if (currentTeam == 2) { clickPoint = new Vector3(Random.Range(495, 5), yCount, Random.Range(5, 495)); } finalPosition = grid.GetNearestPointOnGrid(clickPoint, yCount); //Getting the position for the building to spawn at //Instantiating of the building if (money - 200 >= 0 && grid.spawn) { units[unit].transform.position = finalPosition; money -= 200; Instantiate(units[unit], finalPosition, Quaternion.identity); } }