question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

VRTK_Interact_Grab NullReferenceException

See original GitHub issue

Using the interact_grab script on the controller on a default steamvr 1.1.0 camera rig will yield two nullreferenceexceptions.

NullReferenceException: Object reference not set to an instance of an object
VRTK_InteractGrab.Start () (at Assets/SteamVR_Unity_Toolkit/Scripts/VRTK_InteractGrab.cs:95)
NullReferenceException: Object reference not set to an instance of an object
VRTK_InteractGrab.Update () (at Assets/SteamVR_Unity_Toolkit/Scripts/VRTK_InteractGrab.cs:395)

which is

controllerAttachPoint = transform.GetChild(0).Find("tip").GetChild(0).GetComponent<Rigidbody>();

These is quite logical when looking at the order. SteamVR initializes the models lazily so the “tip” will only be created after some frames when the model is loaded. The lookup for the attachpoint should therefore also be delayed. A better way of doing it is probably to not do it once but wrap it into a “getAttachPoint” method that does the lookup ondemand if it is not done already or got reset (think of exchanging the controller model during play).

I was curious why it works in the examples and as it seems the model hierarchy was baked into the scene. That explains the difference but will only work with the example setup and not with the pure steamvr prefab.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:10 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
thestonefoxcommented, Jun 5, 2016

The reason the camera rig prefab is different is because the steam vr plugin comes with 2. The one in the prefabs folder (the one you’re referring to) and the one in the test_throw example scene with the elements there in the editor (as explained in the readme of this repo).

The camera rig prefab included in this repo is the one from the test throw scene. I need to understand why valve included two in their repo before feeling comfortable removing the prefab from this repo.

In short, your issue is being caused because you’re not using the prefab from this repo

Read more comments on GitHub >

github_iconTop Results From Across the Web

XR Interaction Toolkit throwing NullReferenceException?
Hi, I am running into a problem with my XR Rig. I have multiple locomotion providers (snap/smooth turn, teleportation/smooth movement) and ...
Read more >
Completely devoid of details · Issue #3858 · dotnet/runtime ...
If I get a NullReferenceException on this line, there are three different objects that could have been null and caused the error ...
Read more >
NullReferenceException : r/virtualreality
Hello Everyone, I am new to Vr, I am creating a Vr android app but I am facing some problems. I have given...
Read more >
Random NullReferenceException on Asp.Net Core 2.1.1 ...
I have an Asp.Net Core web site with a view that is bound to a simple view model. .NET Framework 4.6.1 Microsoft.AspNetCore 2.1.1....
Read more >
Fix Null Reference Exception in Unity - YouTube
Here I have another debugging tutorial on how to fix a NullReferenceException error in Unity. This lesson will teach you more about ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found