Quantcast
Channel: Answers for "Why is this null? Finding a script on an object"
Viewing all articles
Browse latest Browse all 6

Answer by rutter

$
0
0
Did you set `controller` in the inspector? Are you sure that the component's name is spelled exactly as you have it listed? Double check that the component is attached to the object you're trying to access. Finally, you might try moving that `GetComponent()` call into an `Awake()` function, like so: var otherGuy : OtherGuyComponent; function Awake() { otherGuy = GetComponent(OtherGuyComponent); } I personally don't recommend using GetComponent with string arguments. It works, but doesn't expose programming errors as early and only gives you generic "component" reference, which usually isn't ideal.

Viewing all articles
Browse latest Browse all 6

Latest Images

Trending Articles



Latest Images