Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 CalculatedCultivator · Apr 01 at 02:58 PM · c#inputoculusdevices

Using Oculus headgear position as input.

I have been trying to use the oculus headgear position as a modifier the speed of a space shooter (chin tucked in means slower speed). However I've run into two problems.

  1. I'm trying to use a script on an empty object to pass on the speedModifier variable to use in other scripts, however it doesn't get any input.

      using System.Collections;
         using System.Collections.Generic;
         using UnityEngine;
         using UnityEngine.XR;
         
         public class HeadgearModifier : MonoBehaviour
         {
         private InputDevice headgear;
         public float headgearModifier;
         public float throttle;
         public float devicePos;
         public Vector3 deviceVector;
     
         void Start()
         {
             List<InputDevice> devices = new List<InputDevice>();
             InputDeviceCharacteristics headgearCharacteristics = InputDeviceCharacteristics.Camera;
             InputDevices.GetDevicesWithCharacteristics(headgearCharacteristics, devices);
     
             if (devices.Count > 0)
             {
                 headgear = devices[0];
             }
         }
     
         void Update()
         {
             headgear.TryGetFeatureValue(CommonUsages.devicePosition, out Vector3 devicePositionValue);
             devicePos = devicePositionValue.z;
             deviceVector = devicePositionValue;
     
             if (throttle < 0.1f)
             {
                 headgearModifier = 0.1f;
             }
     
             else if (throttle > 1f)
             {
                 headgearModifier = 1f;
             }
     
             else if (throttle < 1f && throttle > 0.1f)
             {
                 headgearModifier = throttle;
             }
         }
     }
    
    
    
  2. This is actually the second method i tried, the first one was simply reference to camera position. however the camera position sometimes got altered somehow (note that i offset the camera to a 3rd person view of the "fighter plane" with the z axis locked (which is the axis i want to use).

      public class FollowPlayerX : MonoBehaviour
         {
             public GameObject plane;
             private Vector3 positionOffset = new Vector3(0, 1, -10);
         
             void Update()
             {
                 transform.position = plane.transform.position + positionOffset;
                 
             }
         }
    
     
    

If anyone could help me with this i'd be very thankful. Cheers!

Comment
Add comment · Show 1
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 CalculatedCultivator · Apr 09 at 12:30 PM 0
Share

I still haven't found the solution to this problem.

0 Replies

· Add your reply
  • Sort: 

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

168 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

Related Questions

Oculus Controller Input only partially working? 1 Answer

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

(C#) A better way to limit actions to once per button press? 2 Answers

Double tap mechanics and axis inputs 3 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