- Home /
Set script variable to gameObject
So I need to link the gameObject to a variable, but when I try the following
static var target : gameObject;
I get "The name "gameObject" does not denote a valid type ("not found"). Did you mean "UnityEditor.GameObjectUtility"?"
Answer by RyanPaterson · Jun 17, 2014 at 06:00 PM
gameObject is different to GameObject (the capitalisation is very important)
You can find the proper definitions and usages here by searching them -
http://docs.unity3d.com/412/Documentation/ScriptReference/GameObject.html
Also, I'd be willing to bet that you don't really want that static
modifier there....
Of course. What the hell was I thinking? I musta been drunk at the time of writing...
Your answer
![](https://koobas.hobune.stream/wayback/20220613151759im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How would I be able to subtract from a variable when it hits something? (OnCollisionEnter) 1 Answer
Acces to a var from another Script. 2 Answers
How do I change the text of a GUIText object through another GameObject using a variable? 2 Answers
Scripts accessing one another (JS) 0 Answers
Switching Gameobjects in a variable 1 Answer