I have a reference to a class, which contains a Transform type variable. Debug.Log(playerController.rigT.position);. Beginner stuff.
When I do this I get both the correct Debug.Log output and a NullReference Exception.
I just don’t even know where to start on that. It’s freaking me out.
Man being a newbie sometimes. It’s the longest component list I have had yet, to be fair. (the SteamVR Camera Rig Camera (head) object - for now anyway) and this script is only 3 inspector lines.
My “gotcha” was that I had two copies of the script. HOWEVER, I probably overlooked it because the duplicate was disabled. Despite being disabled the script still sends Debug.Log messages?! - since I had sorted one up the list of components, I wasn’t seeing both at the same time.
The solution was in just tearing everything off the object one script component at a time.
Staying organized is as important as understanding Unity and knowing basic programming conventions for the independent developer. More and more I am of the opinion that the first step is “Learn programming and how to organize yourself.”
Don’t feel bad! Even though I have many years of programming experience I sometimes have the same type of Errors in Unity,
For instance dragging a component to a wrong item in the hierarchy , getting disturbed by someone and forgetting to fix it and 2 weeks later you get an error that you don’t understand What I sometimes wish I could do in unity was to lock away the parts of the data / hierarchy in edit mode, that I wasn’t using so it would not get messed up becaurse of silly mistakes in editmode.
There is a trick you can do in the hierarchy to find duplicates though you can search for “t:ComponentClassName” and then all objects will show that holds a certain component.