Unable to hide 3D character

Hi,

I am unable to hide a 3D character using renderer.enabled=false;

function Start () {
		GameObject.Find("Female_v01").renderer.enabled=false;

}

This is the error msg I get

MissingComponentException: There is no ‘Renderer’ attached to the “Female_v01” game object, but a script is trying to access it.
You probably need to add a Renderer to the game object “Female_v01”. Or your script needs to check if the component is attached before using it.

How do I add a renderer to the character? The character is being rendered though.

I am able to translate, rotate the character etc using the above GameObject.Find

Thanks in advance

When you bring a character in from a 3d app (like maya for instance) everything in the scene is grouped under one gameobject in unity, but opening the heirarchy of that object will reveal all of its child objects, such as your bones and the actual geometry of your character.

My guess is your file is named Female_v01, but your actual geometry (the thing that actual has a renderer) is something else entirely. Your script should be searching for that instead.

renderer.enabled=false works on a cube though;

I even added a mesh renderer to the object but it still doesnt work.

:frowning:

Thanks Mr. Animator,

I will try what you suggested.

Thanks Mr. Animator,

That worked :slight_smile:

Except the eyeballs were still visible because they were separate spheres. Will have the animators solve that one lol

would highly recommend that, as seperate (animated) object = additional draw calls

Or maybe you can just deactivate the whole character with

gameObject.active = false;

This would work too, but it would also deactivate any attached scripts as well, which might be undesirable.