Camera Find?

Hello.

I’m trying to locate a camera located in the hirarchy of a gameobject how can I do it?

myCam = GameObject.Find(“Camera”);

myCam.enabled = true;

just returns failed, due to gameObject being returned to Camera?

HELP

I’ve made it find a camera called Camera but how can I specify it’s the camera called Camera in this object

Can you actually post all of the code?

GameObject.Find searches the entire scene. You may want to consider using GameObject.GetComponentInChildren if the Camera component is added to a child object. If the camera component is part of the highest object in your transform hierarchy, then you can just use GetComponent.

Hi
I had the same problem and found the solution.
Find can’t be used with a camera, so if you want to enable or disable the object found as a camera you’ll have to do this:

var myCam : GameObject;

function Start()
{
   myCam = GameObject.Find("Camera01"); 
   (myCam.GetComponent(Camera) as Camera).enabled = true;

}

hope it would help any newbie like me, and not waist a lot of time searching a solution as i did…