//spawn new trap protected void SpawnTrap() { if (_trapPrices[_trapToBuild] <= _generalController.GetGold()) { _generalController.SubtractGold(_trapPrices[_trapToBuild]); GameObject newTrap = Instantiate(_allTraps[_trapToBuild], _currentTrap.transform.position, _currentTrap.transform.rotation) as GameObject; GameObject hierachyTraps = GameObject.FindGameObjectWithTag("AllTraps"); newTrap.transform.parent = hierachyTraps.transform; Destroy(_currentTrap.gameObject); isBuilding = false; _trapToBuild = -1; } else { Destroy(_currentTrap.gameObject); isBuilding = false; _trapToBuild = -1; } }