I have been following along with a Lynda.com video course to familiarize with Unity. I am currently attempting to grab a reference to a scene's First Person Controller's transform as follows:
Transform targetObject;
// Use this for initialization
void Start ()
{
targetObject = gameObject.Find("First Person Controller").transform;
}
And this is within a script/class that inherits from MonoBehaviour
. However, this gives the error:
Static member `UnityEngine.GameObject.Find(string)' cannot be accessed with an instance reference, qualify it with a type name instead
I am sure there is a way to just change the logic and get the desired affect with a different approach. But I do not understand why this results in an error. It is the same code used by the instructor of the course, and from the Unity Script Reference, I can see that MonoBehaviour
inherits a gameObject
member which has the Find()
method. So this error is saying there is only one GameObject
instance for all MonoBehaviour
classes right? But shouldn't I still be able to call it's methods?
I am using Unity 4.1 with C# while the instructor is using 3.5 (with JS) if that helps any.