Hey folks, I have a question about scripting for the Motion Controllers: I would like to write a script that gets the 6DoF grip pose rotation from my left Motion Controller (Specifically the Y rotation) and applies that rotation to a game object. I've written scripts that do this for game objects, but I'm having a tough time figuring out where to begin when it comes to making an object to get it's rotation from a Motion Controller. As an example of what I'm trying to do, here's a script I wrote that makes a game object match the Y rotation of another game object: Code (CSharp): using System.Collections; using System.Collections.Generic; using UnityEngine; public class GetYRotation : MonoBehaviour { public GameObject YParent; void Update () { transform.localEulerAngles = new Vector3(0.0f, YParent.transform.localEulerAngles.y, 0.0f); } } So basically, I'd like to write a script that does that, but instead of getting the rotation from a game object, it gets the rotation from Motion Controller's rotation. I know you can get the Motion Controller rotation from XR.InputTracking.GetLocalRotation, but I'm having a tough time scripting for anything XR.WSA.Input related so far. (Yes, I'm still new to this.) I'm sure you experienced devs will get a laugh from this- Code (CSharp): using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.XR.WSA.Input; namespace HoloToolkit.Unity.InputModule public class GetMotionControRotation : MonoBehaviour { void Update () { transform.localEulerAngles = InputTracking.GetLocalRotation(XRNode.LeftHand); } } That just created a bunch of errors. Am I completely on the wrong track here? If you have any suggestions, or if you know of any good tutorials on getting started with scripting for XR.WSA.Input related things, I'd really appreciate it. Thanks!
Hey COLiTRON, You can query a controllers position, rotation, and buttons using the Interaction Manager https://docs.unity3d.com/ScriptReference/XR.WSA.Input.InteractionManager.html and also https://docs.unity3d.com/ScriptReference/XR.WSA.Input.InteractionSourcePose.html I think those might be an easier way of accessing the information you're after.
Thanks Jason! I'll give those a shot. Also, I recently realized that I've been using Visual Studio without the right configurations setup. I must have glazed over that when I installed the HoloToolKit months ago. I've sorta been working with one hand tied behind my back this whole time. Oops.
But you could go down in history as the man who conquered MR Input one-handed! Anyways, glad it might have opened up a path forward. Let us know if you have any other questions!
COLiTRON, that ever work out for you? I also got a WMR headset and became interested in Unity3d. But understanding the controller setup was difficult to get into.