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 /
avatar image
0
Question by Saint34x · Mar 16, 2018 at 12:26 AM · inputtriggercontrolleroculusoculus rift

oculus rift single shot on SecondaryIndexTrigger pull

Greeting Everyone! thanks for stopping by to help me with my issue!

alright so im working on a shooter for the Oculus but when i pull the trigger it fires of all the ammo in my gun very rapidly. since the player is using a revolver this is less than ideal.

i understand that the OVRInput.Get(OVRInput.Axis1D.SecondaryIndexTrigger) returns a 0.0f - 1.0f float.

so what im doing is something like this :

  if (isRightHand)
         {
             indexTriggerState = OVRInput.Get(OVRInput.Axis1D.SecondaryIndexTrigger, Controller);
        }
         if (indexTriggerState <= 0.1f)
         {
             shotFiredOnTrigger = false;
         }

then later :

   if(indexTriggerState >= 0.95f && !lastFrameFired)
             if (isRightHand)
             {
          
                     if (ammoCount >= 1)
                     {
                         shootGun();
                     }
                     else {
                         ammoEmpty();
                     }
                     lastFrameFired = true;
     }


basically it checks for the float value of the trigger. if its almost all the way pulled it tells the game to fire a shot, and sets a bool to say "hey i just fired. don't fire again until the trigger is almost entirely let off.

easy and simple. But te problem is it seems like the float for IndexTriggerState reached .9999 something something on frame then even with the trigger still pulled it drops back down to 0.02 or something really low like that.

im not a great coder but im not awful. this is the first project ive done with oculus and i feel like im beating my head against a wall with this and im sure the answer is right there in front of me i just cant see the trees through the forest.

any help you guys can offer would be greatly appreciated.

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

Answer by cvid · Mar 17, 2018 at 01:01 PM

Hi, @Saint34x

Instead of OVRInput.Get you can use OVRInput.GetDown with same parameters. These method returns true only once on button down event even if user hold it. In this case there is no need to do any additional checks. For example:

     bool bDown = OVRInput.GetDown(OVRInput.SecondaryIndexTrigger, Controller);
     
     if(bDown)
     {
       Shoot();
     }


Comment
Add comment · Show 3 · 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 Saint34x · Mar 19, 2018 at 02:35 AM 0
Share

Hello @cvid thanks for getting back to me. i really appreciate it! so i tried what you said :

    bool bDown = OVRInput.GetDown(OVRInput.Button.SecondaryIndexTrigger, Controller);
         print(bDown);

this bit makes perfect sense to me and was what i tried to do at first but i wasnt casting the input as its own bool and was trying to check it directly with an if statement. that didnt work. haha

but for some reason this always returns false. is there something else im missing ?

thank you again for your help.

avatar image cvid Saint34x · Mar 20, 2018 at 12:18 PM 1
Share

Sorry it was my fault. I've just checked it and correct script will be:

 bool bDownLeft = OVRInput.GetDown(OVRInput.Button.PrimaryIndexTrigger, OVRInput.Controller.LTouch); // for left hand
 
 bool bDownRight = OVRInput.GetDown(OVRInput.Button.PrimaryIndexTrigger, OVRInput.Controller.RTouch); // for right hand

As axis it's called Secondary, but for button is called Primary. I really don't know why.

Please note that you need a OVR$$anonymous$$anager instance on scene and in addition you should setup XR settings section in Player Settings with Oculus SD$$anonymous$$. Hope it'll be helpful.

avatar image Saint34x cvid · Mar 21, 2018 at 04:15 PM 0
Share

yes!! this works perfectly! thank you so much! you are a life saver.

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

113 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

Related Questions

cannot read button input from oculus go (but able to read rotation) 0 Answers

XR Interaction Toolkit Preview detecting wrong controller 1 Answer

OpenXR Continuous Turn and Movement not working 0 Answers

Gamepad stops working with Oculus Rift attached 0 Answers

How to get VR controls working again after update to 2019.1.0f2? 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