- Home /
Activating Game Objects
hey guys, sorry if this is a simple question but im fully stumped...
i wanna make it so when i pick up a item it makes another item visble... for exsample i want it so if i press E on a bsic white box it goes away and makes it so another box shows up and becomes visble... is there any scripts that make it so i can pick up white box with E and it sets the other box to active so it appears on stage??
thanks heaps
Answer by Doeko · Jan 12, 2014 at 11:27 AM
Depending on what oyu want to achieve you can do a number of different things.
You can use
gameObject.SetActive(false);
however it will also disable the entire object's tree (the lower levels). If you just want it to become invisible and nothing else, it is better (imo) to use
gameObject.GetComponent<MeshRender>().enabled = false;
Answer by edcarlo · Jan 12, 2014 at 11:22 AM
You can activate gameObjects by this:
gameObject.SetActive(true);
Answer by morbidcamel · Jan 12, 2014 at 11:39 AM
Afraid not - you have to write it yourself. It should be simple enough once you go through some scripting tutorials. You can use GameObject.SetActive to activate or deactivate an object
Your answer
![](https://koobas.hobune.stream/wayback/20220613130141im_/https://answers.unity.com/themes/thub/images/avi.jpg)