Hello,
I do not know if someone will understand my problem but I post here just in case. I created 3 scenes in a unity project and I also made a button allowing to switch between the 3 scenes, however when I access another scene I have a message like this which appears at my FPScontroller and more particularly of the script allowing navigation with a joystick in VR.
My character blocks in my scene and finds me an error:
NullReferenceException: Object reference not set to an instance of an object
VRNavigationControllerPara.FixedUpdate () (at Assets/MiddleVR_FirstPersonController/VRNavigationControllerPara.cs:107)
And here are the code : with the problem line 107.
Do you have a solution to resolve this problem…?
Thanks a lot !
Antonin G
5450268–556083–VRNavigationControllerPara.cs (4 KB)
Maybe your m_head Gameobject is not being referenced properly.
Try making it public or add [SerializeField] in front of the line where you declare the variable (19)
Make sure it’s finding the right object on running the game.
I would suggest using [SerializeField] and assigning the reference directly in the inspector. That way you can still keep the object private.
Hello TheGameNewBie,
First of all, thank you very much for you reply,
I don’t understand how to add [SerializeField] ?
Like this ? → line19: [SerializeField] GameObject m_Head;
And how to assign the reference directly to inspector ?
Sorry, but I’m still beginner in programming…
Thanks for your reply!
/Antonin
Yep, What you’re doing is right. After adding that, You’ll see a field in the inspector.

Next, In the editor, Drag your “HeadNode” object from the hierarchy in this field.
Oh my god thanks a lot!
I finally add FirstpersonCharacter (so my camera) because I don’t have any Object called HeadNode
As you can see on the screenshot here.
Thank you
So, that’s why you were getting the NullReferenceException error. Because At line 36,
m_Head = GameObject.Find("HeadNode");
You were trying to get the object “HeadNode” in the scene. There was no object, So it is giving you the error.