Hello all,
I am having the above problem with the attached script. Line 25. I have tried moving this line around such that it is after the assignment of trackedObj, but I end up with more errors.
Thanks in advance for your help
3000843–223706–WandManagerVIVE.cs (2.33 KB)
The placement of that particular line (25) isn’t what matters, but rather the placement of the line that calls it.
You’re getting the error because trackedObj is null. trackedObj is set in Start() on line 43. However, immediately before that happens, you check (controller == null) - this causes line 25 to be executed, which triggers the exception.
And because it’s throwing an exception, the execution of Start() is halted, meaning that line 43 never gets called, so trackedObj remains null.
Move line 43 above that if statement, and it should work fine.
Having moved line 43 to line 36, I am still getting the error. Still reports Line 25 NRE…
Is the script attached to the exact same GameObject as the TrackedObject (e.g. the controller or headset object)?
No it is attached to a different object, … would it necessarily matter?
Yes. GetComponent will only find other components on that same object.