Jump to content
Happy Holidays! Limited Staff Responses: 1/20 - 1/31 ×

How can I get Focus controller's position in Unity?


akira fan
 Share

Recommended Posts

Hi,

I have tried the following code. I can get the rotation of the controller but the when I try to get the position, it always gives me 0,0,0. Is there a way to get the position of the controller?

 

Thank you

public WVR_DeviceType device = WVR_DeviceType.WVR_DeviceType_Controller_Right;public GameObject modelGO;void Update () {        WaveVR_Utils.RigidTransform trans = WaveVR_Controller.Input(device).transform;        modelGO.transform.position = trans.pos;        modelGO.transform.rotation = trans.rot;}
    private WVR_DevicePosePair_t[] poses = new WVR_DevicePosePair_t[3];  // HMD, R, L controllers.    public WVR_DeviceType device = WVR_DeviceType.WVR_DeviceType_Controller_Right;    private WaveVR_Utils.RigidTransform[] rtPoses = new WaveVR_Utils.RigidTransform[3];public GameObject modelGO;void Update () {        WaveVR.Device _device = WaveVR.Instance.getDeviceByType(device);        WVR_DeviceType _type = _device.type;        WVR_PoseOriginModel origin = WVR_PoseOriginModel.WVR_PoseOriginModel_OriginOnGround;        Interop.WVR_GetSyncPose(origin, poses, (uint)poses.Length);        for (int i = 0; i < poses.Length; i++)        {            if (poses[i].type == _type && poses[i].pose.IsValidPose)            {                rtPoses[i].update(poses[i].pose.PoseMatrix);                updatePose(rtPoses[i]);                break;            }        }}    public void updatePose(WaveVR_Utils.RigidTransform pose)    {        modelGO.transform.localPosition = pose.pos;        modelGO.transform.localRotation = pose.rot;    }
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...