• 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
Question by sHajir · Nov 22, 2016 at 07:01 PM · inputvrcontrollerfalse

SteamVR_Controller.GetPress , GetPressDown, GetPressUp always returns false !

 using UnityEngine;
 using System.Collections;
 using Valve.VR;
 
 public class WandController : MonoBehaviour {
     private EVRButtonId triggerButton = EVRButtonId.k_EButton_SteamVR_Trigger;  
     public bool triggerButtonDown = false;
     public bool triggerButtonUp = false;
     public bool triggerButtonPressed = false;
 
     private EVRButtonId gripButton = EVRButtonId.k_EButton_Grip;               
     public bool gripButtonDown = false;
     public bool gripButtonUp = false;
     public bool gripButtonPressed = false;
 
     private SteamVR_Controller.Device controller { get { return SteamVR_Controller.Input((int) trackedObj.index); } } 
     private SteamVR_TrackedObject trackedObj;
 
     void Start () {
         trackedObj = GetComponent<SteamVR_TrackedObject>();
         Debug.Log("trackedObj: "+trackedObj);                   //trackedObj is never null
     }
     
     // Update is called once per frame
     void Update () {
         if (controller == null)
         {
             Debug.Log("Controler Object ist null");             // controller object is never null
             return;
         }
 
 
         gripButtonDown = controller.GetPressDown(gripButton);   //is always false, also when pressing gripButton
         gripButtonUp = controller.GetPressUp(gripButton);
         gripButtonPressed = controller.GetPress(gripButton);
 
         
 
         triggerButtonDown = controller.GetPressDown(triggerButton);
         triggerButtonUp = controller.GetPressUp(triggerButton);
         triggerButtonPressed = controller.GetPress(triggerButton);
         Debug.Log("triggerButton: "+ controller.GetPress(triggerButton));  //is always false, also when pressing triggerButton
         Debug.Log("triggerButtonDown: " + triggerButtonDown);              //is always false, also when pressing triggerButton
 
 
 //content of these if-statements never get activated/run -> also when pressing all Buttons permanently ! 
         if (gripButtonDown)
         {
             Debug.Log("Grip Button was just pressed");
         }
 
 
         if (gripButtonUp)
         {
             Debug.Log("Grip Button was just unpressed");
         }
 
 
         if (triggerButtonDown)
         {
             Debug.Log("Trigger Button was just pressed");
         }
 
 
         if (triggerButtonUp)
         {
             Debug.Log("Trigger Button was just unpressed");
         }
 
     }
 }

This script is attached to 'Controller (left)'.

Why do the methods 'controller.GetPressUp(gripButton); controller.GetPressDown(gripButton); controller.GetPressDown(triggerButton);' etc. always return false ; even though I'm pressing all the Buttons(Trigger, Grip, and all other buttons) on the Vive controller (left) ?

Thanks

Comment

People who like this

0 Show 0
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

2 Replies

  • Sort: 
avatar image

Answer by Wiechering · Aug 04, 2017 at 01:52 PM

I now this is a very old Topic. Nevertheless i wanted to add a solution that (at least for me) works and ansers the question:

 void Update () {
         if ( Controller.GetPressDown (SteamVR_Controller.ButtonMask.Grip)) {
             do_something();
         }
         if (Controller.GetPressUp (SteamVR_Controller.ButtonMask.Grip)) {
             do_something_else();
         }
     }
Comment
Eliza993

People who like this

1 Show 0 · 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
avatar image

Answer by RIDENTEM · Sep 16, 2018 at 03:28 PM

For anyone else who crosses this post and has the same problem I did, this solution did not work for me. Instead after poking around what finally worked for me was this:

  public SteamVR_TrackedController controller;
 
 void Start()
 {
 controller =  GetComponent<SteamVR_TrackedController>();    
 }
 
  void Update () {
        if(  controller.triggerPressed == true)
 Debug.Log("A trigger has been pressed");
      }


Comment

People who like this

0 Show 0 · 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

Unity Answers is in Read-Only mode

Unity Answers content will be migrated to a new Community platform and we are aiming to launch a public beta by June 9. Please note, Unity Answers is now in read-only so we can prepare for the final data migration.

For more information and updates, please read our full announcement thread in the Unity Forum.

Follow this Question

Answers Answers and Comments

100 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

Related Questions

OpenVR + SteamVR: simulate other controllers 0 Answers

Input System can't find Valve knuckle controllers 0 Answers

How to disable Vive Controllers 5.5 support 1 Answer

Xbox one controller spinning 0 Answers

JoyCons not working with vJoy 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