how to hide a GameObject?

I have two cameras----First Person camera and Third Person Camera. First Person camera is inside the model of a GameObject and the Third Person camera follows it. When I switch to the First Person camera, I see part of the model because the camera is inside of it. How can I hide the GameObject when I switch to the First Person camera? Is there some fuction like “GameObject.visible=false” or something else?

Please explain in details as I’m a beginner. Thank you very much!

Disabling the GameObject is easy. You can quickly do that with the function SetActive:


This will however disable all components on the GameObject and any child GameObjects it has. You probably rather want to disable just the renderers. You are not giving a lot of details about your setup, but you are using either MeshRenderer or SkinnedMeshRenderer to render your player.

Search for the appropriate one and disable it by setting its enabled variable to false:

MeshRenderer render = gameObject.GetComponentInChildren<MeshRenderer>();

render.enabled = false;

The airplane model is made by “3ds max” and imported into unity. It’s black in unity. Why? And how can I colour it?

Because you don’t have material, you need to add material to have a color

The thing that worked for me was just setting a parent object’s scale to zero. This will “hide” any object that is under that parent and you don’t have to worry about disabling any components.