Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Virtual Reality Room-Scale VR Interacting with Objects Picking Up an Object

Brad Pizzimenti
Brad Pizzimenti
14,631 Points

I cannot pickup the basketball object and I'm getting a NullReferenceException

Though the project will run, I'm getting a recurring null ref exception in the conosle:

NullReferenceException: Object reference not set to an instance of an object ControllerInteraction.OnTriggerStay (UnityEngine.Collider other) (at Assets/Scripts/ControllerInteraction.cs:37)

Line 37 that it refers to is my IF statement and reads as follows:

    if (device.GetTouch(SteamVR_Controller.ButtonMask.Trigger)
          && other.GetComponent<Rigidbody>() != null
          && fixedJoint == null)

It seems that the null reference it's complaining about is "device" but device is instantiated in FixedUpdate and I had not trouble with the material.color test we ran in the previous video.