I made a art for a chest, one is open and another is closed, and i want to make a script when player collide with chest and press E or open button to destroy that chest that is closed and create a chest that is open.
I made a script only for destroying because i dunno what should i use to create a new object .
Here is script :
if (kovcegtxt) {
if (Input.GetButtonDown ("Open")) {
Destroy (kovceg);
kovcegtxt = false;
ChestUI.SetActive (false);
}
There is kovcegtxt just for when collide to show some text.
Chest is “kovceg” in here.
kovceg is defined like this :
kovceg = GameObject.FindGameObjectWithTag ("Zkovceg");