IEnumerator destroyAndRecreate() { stoneWoodText stoneWoodScript = GameObject.Find("StoneWoodText").GetComponent <stoneWoodText>(); stoneWoodScript.stone++; crumbleAudioSrc.PlayOneShot(rockCrumble); gameObject.GetComponent <Renderer>().enabled = false; yield return(new WaitForSeconds(respawnTime)); gameObject.GetComponent <Renderer>().enabled = true; pickaxeSwings = 0; }
IEnumerator destroyAndRecreate() { stoneWoodText stoneWoodScript = GameObject.Find("StoneWoodText").GetComponent <stoneWoodText>(); stoneWoodScript.wood++; chopAudiosrc.PlayOneShot(treeChop); gameObject.GetComponent <Renderer>().enabled = false; yield return(new WaitForSeconds(respawnTime)); gameObject.GetComponent <Renderer>().enabled = true; axeSwings = 0; }
// Update is called once per frame void Update() { stoneWoodText stoneWoodScript = GameObject.Find("StoneWoodText").GetComponent <stoneWoodText>(); if (stoneWoodScript.tier1Spawned) { gameObject.GetComponent <Renderer>().enabled = true; gameObject.GetComponent <BoxCollider>().enabled = true; } else if (gameObject.GetComponent <Renderer>().enabled == true) { gameObject.GetComponent <Renderer>().enabled = false; gameObject.GetComponent <BoxCollider>().enabled = false; } }