please ! is it possible to hide a gameobject in unity without applying the destroy method ? cz the destroy method detroys all of the components of the gameobject
Youâre looking for SetActive(). Use âMyGameObject.SetActive(false)â to deactivate something, and âMyGameObject.SetActive(true)â to turn it back on.
Some other options are to simply move it off the screen out of sight with itâs transform. Or you could also just turn off its mesh renderer if it has one.
Thereâs probably other creative ways to do it. Iâm not sure how performant âSetActiveâ is, but that might be another option. Enable/disable etc.
i donât wanna disable it or other thing , i just need to hide it, because once i use SetActive(false) all the instructions tht come after it doesnât work
then disable the renderer in the gameobject. It will be hidden.
no actually i wanna make this on a trigger, once the player is on the trigger, the gameobject should dessapear, but in same time and in the same script i have a GUI Texture that should appear and gimme some infos , once i disable the gameobject, the GUI and their options dnt work at all
Go try this.
where can i find the renderer ?
meow :3~
Reading all the posts and threads youâve just made, I get the feeling you should have a look at this and get the basics down first: Learn game development w/ Unity | Courses & tutorials in game design, VR, AR, & Real-time 3D | Unity Learn
not working
here is my script
#pragma strict
var CUTE : GUITexture;
function start()
{
CUTE.enabled = false;
renderer.enabled = false;
}
function OnTriggerEnter(otherObj: Collider){
if (otherObj.tag == "Player")
{
Debug.Log("hello");
CUTE.enabled = true;
yield WaitForSeconds (5);
CUTE.enabled = false;
this.gameObject.active = false;
}
}
all i need is to hide the gameobject, before the CUTE dissapear
if (SOMETHING_HAPPENS) {
renderer.enabled = false;
collision.enabled = false; // Disable the collision too, just disabling the renderer will not automatically turn off collision/collider and/or trigger, meaning the object is basically still in-tact.
} else {
renderer.enabled = true;
collision.enabled = true;
}
As for your code, programming works like a list: you go from top to bottom.
So put the ârenderer.enabled = false;â portion above âCUTE.enabled = false;â one to make the object disappear before CUTE.
Also, I noticed that you enable and disable CUTE on trigger, but you never turn on its renderer.
In this case you can also consider to replace ârenderer.enabled = false;â to a simple untick in the inspector.