So I have this script that when I press t it spawns a wood plank in front of you that you can place down. However I can’t get the board to go away when you press the same button. Any ideas on how I could do this? Here’s the script:
if (Input.GetKeyUp("t") && woodAvailable > 0) {
if ( buildingMaterial == true) {
Destroy(obstacleToBuild);
buildingMaterial = false;
}
if (buildingMaterial == false){
playerPosition = transform.position;
playerRotation = transform.rotation;
obstacleToBuild = Instantiate(woodPlank, myGamobject.transform.FindChild("Main Camera").position + 3f * Vector3.forward, myGamobject.transform.FindChild("Main Camera").rotation) as GameObject;
obstacleToBuild.transform.parent = myGamobject.transform.FindChild("Main Camera");
buildingMaterial = true;
}
}