Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • 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 /
  • Help Room /
avatar image
0
Question by 265lutab · Dec 01, 2018 at 02:15 AM · inputvr

Vive controller input not working

I'm trying to put Vive controller input using the native unity input system and it is not registering any button presses on the Vive controllers. I'm using unity 2018.2.10f1 and have Steam VR in my project. The controllers are visible in play mode and I have a raycast script on them that is working to point at things, but I am not able to register any button presses.

The input settings I have in the project alt text

The code where I'm using it

         print(Input.GetButton("SelectObject")); //debug to see if I'm getting any input from Vive
         if ((Input.GetMouseButtonDown(0) || Input.GetKeyDown("joystick button 0")) && affectedSphere.sphereHover && !affectedSphere.sphereHit)

My full script

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class ControllerRaycast : MonoBehaviour {
 
     public string interactionItemTag = "SoundObject";
 
     SoundObject affectedSphere;
     bool sphereInteraction;
 
     private void Start()
     {
         affectedSphere = FindObjectOfType<SoundObject>(); //used to prevent errors with no selected sound object
     }
 
     void Update () {
         RaycastHit hit;
         Ray pointerRay = new Ray(transform.position, transform.forward);
         Debug.DrawRay(transform.position, transform.forward, Color.green);
 
 
         print(Input.GetButton("SelectObject")); //debug to see if I'm getting any input from Vive
         if ((Input.GetMouseButtonDown(0) || Input.GetKeyDown("joystick button 0")) && affectedSphere.sphereHover && !affectedSphere.sphereHit)
         {
             print("mouse click");
             SphereActivate();
         }
         if (!sphereInteraction)
         {
             if (Physics.Raycast(pointerRay, out hit))
             {
                 if (hit.collider.tag == interactionItemTag)
                 {
                     affectedSphere = hit.collider.GetComponent<SoundObject>();
                     if (!affectedSphere.sphereHit)
                         SphereHover();
                 }
             }
         }
         else if (!affectedSphere.sphereHit)
         {
             if (Physics.Raycast(pointerRay, out hit))
             {
                 if (hit.collider.tag != interactionItemTag)
                 {
                     SphereExit();
                 }
             }
             else
             {
                 SphereExit();
             }
         }
     }
 
     void SphereHover()
     {
         affectedSphere.sphereHover = true;
         sphereInteraction = true;
         affectedSphere.ObjectHover();
     }
 
     void SphereExit()
     {
         affectedSphere.sphereHover = false;
         sphereInteraction = false;
         affectedSphere.ObjectExit();
     }
 
     void SphereActivate()
     {
         affectedSphere.sphereHit = true;
         sphereInteraction = false;
         affectedSphere.ObjectActivate();
     }
 
     void SphereDeactivate()
     {
         affectedSphere.sphereHit = false;
         affectedSphere.ObjectDeactivate();
     }
 }
 


input-setup.jpg (117.7 kB)
Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by cisin · Feb 01, 2019 at 04:16 PM

 1.    using System.Collections;
 2.     using System.Collections.Generic;
 3.     using UnityEngine;
 4.     
 5.     public class ControllerRaycast : MonoBehaviour {
 6.     
 7.         public string interactionItemTag = "SoundObject";
 8.     
 9.         SoundObject affectedSphere;
 10.         bool sphereInteraction;
 11.     
 12.         private void Start()
 13.         {
 14.             affectedSphere = FindObjectOfType<SoundObject>(); //used to prevent errors with no selected sound object
 15.         }
 16.     
 17.         void Update () {
 18.             RaycastHit hit;
 19.             Ray pointerRay = new Ray(transform.position, transform.forward);
 20.             Debug.DrawRay(transform.position, transform.forward, Color.green);
 21.     
 22.     
 23.         //    print(Input.GetButton("SelectObject")); //debug to see if I'm getting any input from Vive
 24.             if ((Input.GetMouseButtonDown(0) || Input.GetKeyDown("SelectObject")) && affectedSphere.sphereHover && !affectedSphere.sphereHit)
 25.             {
 26.                 print("mouse click");
 27.                 SphereActivate();
 28.             }
 29.             if (!sphereInteraction)
 30.             {
 31.                 if (Physics.Raycast(pointerRay, out hit))
 32.                 {
 33.                     if (hit.collider.tag == interactionItemTag)
 34.                     {
 35.                         affectedSphere = hit.collider.GetComponent<SoundObject>();
 36.                         if (!affectedSphere.sphereHit)
 37.                             SphereHover();
 38.                     }
 39.                 }
 40.             }
 41.             else if (!affectedSphere.sphereHit)
 42.             {
 43.                 if (Physics.Raycast(pointerRay, out hit))
 44.                 {
 45.                     if (hit.collider.tag != interactionItemTag)
 46.                     {
 47.                         SphereExit();
 48.                     }
 49.                 }
 50.                 else
 51.                 {
 52.                     SphereExit();
 53.                 }
 54.             }
 55.         }
 56.     
 57.         void SphereHover()
 58.         {
 59.             affectedSphere.sphereHover = true;
 60.             sphereInteraction = true;
 61.             affectedSphere.ObjectHover();
 62.         }
 63.     
 64.         void SphereExit()
 65.         {
 66.             affectedSphere.sphereHover = false;
 67.             sphereInteraction = false;
 68.             affectedSphere.ObjectExit();
 69.         }
 70.     
 71.         void SphereActivate()
 72.         {
 73.             affectedSphere.sphereHit = true;
 74.             sphereInteraction = false;
 75.             affectedSphere.ObjectActivate();
 76.         }
 77.     
 78.         void SphereDeactivate()
 79.         {
 80.             affectedSphere.sphereHit = false;
 81.             affectedSphere.ObjectDeactivate();
 82.         }
 83.     }
 84.     
 85.    
 86.    
Comment
Add comment · Share
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

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

203 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 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 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 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 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Google Cardboard + GazeInputModule: Capture trigger when not activated over UI 0 Answers

How to disable Vive Controllers 5.5 support 1 Answer

Help me doing teleportation with oculus touch 1 Answer

Google Cardboard VR + GazeInputModule - Get trigger events when not over UI 1 Answer

Do I need to use the Input Manager to register all input axes? 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