How Do I Set the Controller Position In a Rotation-Only Environment

Introduction

VIVE Wave™ uses WaveVR_ControllerLoader to load the controller in runtime. Therefore, the controller position cannot be modified in Editor.

Select the Track Position option to track the position of the controller.

_images/qa_3DoF_controllerloader.png

Note

  • If the Track Position option is not selected, the controller will be set to rotation-only.

Go to Set the Position of the Rotation-Only Controller In Runtime to learn how to set the position of the rotation-only controller.

Set the Position of the Rotation-Only Controller In Runtime

Follow the steps below to set the position of the rotation-only controller.

  1. Listen to the CONTROLLER_MODEL_LOADED broadcast to receive the controller instance.
  2. Set the position of the controller instance.
private GameObject dominantController = null, nonDominantController = null;
void OnEnable()
{
    WaveVR_Utils.Event.Listen (WaveVR_Utils.Event.CONTROLLER_MODEL_LOADED, OnControllerLoaded);
}

void OnControllerLoaded(params object[] args)
{
    WaveVR_Controller.EDeviceType _type = (WaveVR_Controller.EDeviceType)args [0];
    if (_type == WaveVR_Controller.EDeviceType.Dominant)
    {
        this.dominantController = (GameObject)args [1];
        // Set to (0, 0, 0)
        this.domintController.transform.localPosition = new Vector3 (0, 0, 0);
    }
    if (_type == WaveVR_Controller.EDeviceType.NonDominant)
    {
        this.nonDominantController = (GameObject)args [1];
        // Set to (0, 0, 0)
        this.noDomiController.transform.localPosition = new Vector3 (0, 0, 0);
    }
}

void OnDisable()
{
    WaveVR_Utils.Event.Remove (WaveVR_Utils.Event.CONTROLLER_MODEL_LOADED, OnControllerLoaded);
}