Hello everyone.

The Mixed Reality Forums here are no longer being used or maintained.

There are a few other places we would like to direct you to for support, both from Microsoft and from the community.

The first way we want to connect with you is our mixed reality developer program, which you can sign up for at https://aka.ms/IWantMR.

For technical questions, please use Stack Overflow, and tag your questions using either hololens or windows-mixed-reality.

If you want to join in discussions, please do so in the HoloDevelopers Slack, which you can join by going to https://aka.ms/holodevelopers, or in our Microsoft Tech Communities forums at https://techcommunity.microsoft.com/t5/mixed-reality/ct-p/MicrosoftMixedReality.

And always feel free to hit us up on Twitter @MxdRealityDev.
Options

Get rotation from Motion Controllers?

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 the Motion Controllers.

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:

`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-

Initially, I hoped that a script like this would at least be a start:

`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!

**- Colin **(Just some weird guy trying to build some weird worlds.)

Best Answer

  • Options
    Answer ✓

    Annnnnd after all that banging my head against the wall... Turns out theres a component in Unity that will apply the position and/or the rotation data of the motion controllers to any game object. Well, that solves that.

    **- Colin **(Just some weird guy trying to build some weird worlds.)

Answers

  • Options
    Answer ✓

    Annnnnd after all that banging my head against the wall... Turns out theres a component in Unity that will apply the position and/or the rotation data of the motion controllers to any game object. Well, that solves that.

    **- Colin **(Just some weird guy trying to build some weird worlds.)

Sign In or Register to comment.