Jump to content
 
Sign in to follow this  
akira fan

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

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;    }

Share this post


Link to post
Share on other sites

Please sign in to comment

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

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...