Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
avatar image
0
Question by banana111 · Feb 26, 2021 at 02:43 PM · inputvrcontrolleroculusquest

new input system with open xr/vr only returns digital/binary trigerr values

I starting development on a VR chess game. Currently, I'm trying to set up hand presence and controller input. I am using the new input system to achieve this. I am trying to get the float value of the second trigger button on the side of my touch 2 controllers. this button is known as the grip button. Here is an image of the button: https://imgur.com/ARh6Er5. Here is the important part of my code:

 void Update()
     {
         float isPressed = controller.selectAction.action.ReadValue<float>();
     }

this float isPressed should be smooth "analog" transition between 0 and 1 (0.1, 0.2, 0.3... 1) based on how far down the grip button is pressed. However, what happens is that it's always either 0 or 1 based on if the button is pressed or not and it behaves more like a bool.

I'm new to the new input system and I wasn't able to find the solution anywhere. I hope someone can help me out here. Thanks in advance.

Here is my whole script (most of it is not important for this problem):

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using UnityEngine.XR.Interaction.Toolkit;
 using TMPro;
 
 public class TestActionInput : MonoBehaviour
 {
     private ActionBasedController controller;
     //public TextMeshProUGUI text;
     public TextMeshPro text;
     // Start is called before the first frame update
     public float isPressed;
     void Start()
     {
         controller = GetComponent<ActionBasedController>();
 
         
 
         controller.selectAction.action.performed += Action_performed;
     }
 
     private void Action_performed(UnityEngine.InputSystem.InputAction.CallbackContext obj) {
         Debug.Log("Select Button is pressed");
     }
 
     // Update is called once per frame
     void Update()
     {
         isPressed = controller.selectAction.action.ReadValue<float>();
         text.text = "" + isPressed;
         //Debug.Log(controller.selectAction.action.ReadValue<float>());
     }
 }
 

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
3
Best Answer

Answer by doleary-3800 · Feb 26, 2021 at 06:34 PM

Hi,

I think this video may help, It demonstrates how to change the grip trigger output to a float value instead of being a button press.

https://www.youtube.com/watch?v=qThlKMMHSpU&t=925s

Hope it helps.

Comment
Add comment · Show 2 · 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 banana111 · Feb 27, 2021 at 10:09 PM 0
Share

It works! I tried changing it from triggerPressed to triggerButton before posting my question and nothing changed. Turns out I had to change it to just trigger, as you said! Sorry for the late response and thanks big time!

avatar image trevor3 · Mar 14 at 06:27 PM 0
Share

Thank you both! I was stuck on this for days. I get the value in a slightly different way using: InputActionReference.action.ReadValue();

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

191 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

Related Questions

How to get VR controls working again after update to 2019.1.0f2? 0 Answers

VR "Hold" Screen for gallery Instal 0 Answers

OVRInput does not work in my script 1 Answer

How to detect button down/up in xr interaction toolkit in unity xr oculus? 0 Answers

OpenXR Continuous Turn and Movement not working 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