• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
This question was closed Mar 14, 2016 at 05:23 PM by Tulsisvt for the following reason:

Solved

avatar image
0
Question by Tulsisvt · Mar 12, 2016 at 11:15 PM · raycastingoculussamsung

Samsung Gear VR Workshop project - null reference error on raycaster script

I'm testing the Gear VR workshop project from Samsung in Unity. I've imported the Oculus Utilities package and the Samsung Gear VR workshop package that has some demo scenes in it. While attaching the rayCaster script to the OVR camera rig I'm getting a null reference exception like this: NullReferenceException: Object reference not set to an instance of an object Raycaster.Update () (at Assets/Workshop/Scripts/Raycaster.cs:17)

The line of error looks like this:

     void Update () {
             **if(InputManager.getInstance().checkForClick()) {** //error on this line
                 RaycastHit hit = new RaycastHit();
                 Vector3 forward = Reticle.getInstance().transform.TransformDirection (Vector3.forward);


and the InputManager class looks like this:

 using UnityEngine;
 using System.Collections;
 
 public class InputManager : SingletonMonoBehaviour<InputManager> {
 
     public bool IsPressed = false;
     
     // Update is called once per frame
     void Update () {
         IsPressed = false;
         detectInputEvents();
     }
 
     // Called every frame from update to check for input events.
     void detectInputEvents() {
         if(Input.GetKeyDown (KeyCode.Mouse0) || Input.GetKeyDown (KeyCode.JoystickButton2)|| Input.GetKeyDown (KeyCode.JoystickButton0)) {
             IsPressed = true;
         }
     }
 
     // Returns true if a main left click, or main joystick event happened. Otherwise, it returns false if no
     // input events were detected.
     public bool checkForClick() {
         return IsPressed;
     }
 }
 

The functions are declared as public and why am I getting a null reference error on that line?

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Tulsisvt · Mar 14, 2016 at 05:25 PM 0
Share

The issue was solved by creating an instance of the Input$$anonymous$$anager in the scene.

avatar image punitp · Jul 10, 2016 at 02:32 PM 1
Share

I guess this issue is co$$anonymous$$g when you are trying to press play button around the end of section "Add a Raycaster to the camera". There is no need to worry and keep following the tutorial. In the next steps, it is explained how to add Input$$anonymous$$anager component and remove this error.

0 Replies

  • Sort: 

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

39 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Recreate Oculus Home room 0 Answers

Reload game scene when take away Gear VR 4 Answers

VR (Camera Fov & GearVR) question ! 0 Answers

Unity on Gear VR with Galaxy S6 2 Answers

Gear VR App only works on Galaxy S7, not older Gear VR phones 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges