Question by
TraffZerr · Dec 12, 2017 at 12:13 AM ·
variablesinstantiationdefinition
NullPointerException with Start, not Update
Hi,
Given this:
var loob = false;
var trigger : Whatever;
function Awake () {
trigger = GameObject.Find("MyObject").GetComponent.<Whatever>();
}
I still don't understand why this works:
function Update () {
//in order to call it once only
if(!loob) {
trigger.TriggerFunction();
loob = true;
}
}
Whereas this won't:
function Start () {
trigger.TriggerFunction();
}
I had encountered this issue many time, and each time I solved it (reading the manual or here) I didn't really get why, and I'm still running into that problem today.
Thanks.
Comment
Your answer
Follow this Question
Related Questions
Firing projectile from Transform. What am I doing wrong? 1 Answer
Getting an object's y coordinate 2 Answers
How to change text based on the value of a scrollbar? 1 Answer
Unreferenced label? 0 Answers