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 TheMaster_123 · Apr 29, 2020 at 04:23 AM · transformpositionvrsteameyes

how to get eye position and rotation steamvr

hey I am making a game where there are portals and I need to get both eyes position and rotation to get the portal effect.

how do I get individual eye positions? thanks in advance.

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

2 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by icehex · Apr 29, 2020 at 07:04 AM

Latest Unity XR (mixed and virtual reality) documentation for getting input: https://docs.unity3d.com/2020.2/Documentation/ScriptReference/XR.InputTracking.html


Since it's fairly new, it isn't very detailed. Also I've never done this before, but give this code snippet a go. It compiles for me but I don't have a VR headset to test it with.

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using UnityEngine.XR;
 
 public class xrnodetest : MonoBehaviour
 {
     public List<XRNodeState> nodeStates;
     private XRNodeState single_xrnode;
 
     private Vector3 left_eye_pos, right_eye_pos;
     private Quaternion left_eye_rot, right_eye_rot;
 
     // Start is called before the first frame update
     void Start()
     {
         nodeStates = new List<XRNodeState>();
 
         // Add left eye node to the nodeStates list, which will be represented by nodeStates[0]
         single_xrnode.nodeType = XRNode.LeftEye;
         nodeStates.Add(single_xrnode);
 
         // Add right eye node to the nodeStates list, which will be represented by nodeStates[1]
         single_xrnode.nodeType = XRNode.RightEye;
         nodeStates.Add(single_xrnode);
 
     }
 
     // Update is called once per frame
     void Update()
     {
         InputTracking.GetNodeStates(nodeStates);
 
         // Try to get the parameters and place them into the correct variables
         nodeStates[0].TryGetPosition(out left_eye_pos);
         nodeStates[0].TryGetRotation(out left_eye_rot);
 
         nodeStates[1].TryGetPosition(out right_eye_pos);
         nodeStates[1].TryGetRotation(out right_eye_rot);
 
 
         Debug.Log("Left eye position: " + left_eye_pos);
         Debug.Log("Left eye rotation: " + left_eye_rot);
         Debug.Log("Right eye position: " + right_eye_pos);
         Debug.Log("Right eye rotation: " + right_eye_rot);
 
     }
 }

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 icehex · Apr 29, 2020 at 05:59 PM 0
Share

I should add that you'll have to name the script "xrnodetest" or change "xrnodetest" in the code above to the name of your script, then attach it to an empty game object or a game object that makes sense so that Start() and Update() get executed when you hit Play.

avatar image TheMaster_123 · Apr 29, 2020 at 11:26 PM 0
Share

it worked thanks

avatar image
0

Answer by TheMaster_123 · Apr 29, 2020 at 07:08 AM

that seems to be for unity 5.6 I am using the latest version of unity.

and I can't access InputTracking it does not appear for me.

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 icehex · Apr 29, 2020 at 09:43 AM 0
Share

Hi @TinyDays please reply to my answer above ins$$anonymous$$d of creating new answers to make a comment. You're right I had the old reference, thanks for the catch! I've updated the answer and put together for you some code you should be able to copy and paste to test. Let me know if it works, I'm also interested in the outcome :-). Thanks!

avatar image TheMaster_123 · Apr 29, 2020 at 05:31 PM 0
Share

oh ok thanks

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

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

Related Questions

Mathf.Abs and How to play animation only if x,z transform has changed by 0.2 units ? 2 Answers

How to get the direction my Steam VR controller is pointing? 0 Answers

during build object moves different position than editor(vr) 1 Answer

Line renderer transform position problem 1 Answer

transform.position 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