- Home /
Question by
Yohan_Games · Oct 14, 2012 at 12:10 PM ·
gameobjectreferencenullexceptionaccess
Accessing other GameObjects Script Variables
Hi there! I am kinda new at this but i have a script here. But i always get a NullReferenceException Everytime i start up the Game :(. I want my Script to Access Other GameObject Variable.
Any Ideas to fix it :)?
Yohan
Comment
Best Answer
Answer by Fattie · Oct 14, 2012 at 12:13 PM
http://docs.unity3d.com/Documentation/ScriptReference/index.Accessing_Other_Components.html
http://docs.unity3d.com/Documentation/ScriptReference/index.Accessing_Other_Game_Objects.html
Answer by Montraydavis · Oct 14, 2012 at 02:15 PM
var OtherComponent : Component ;
OtherComponent = gameObject.GetComponent ( ScriptName ) ;