Customize hardware interaction

  1. Right click under Hierarchy and select Create Empty, then name it XDMsgManager. Create a C# script named XDDeviceControlManager under Assets>Scripts>XDGame and attach that to XDMsgManager

    Screenshot 2024-08-22 113751.png

  2. Declare the following variables

    public SteamVR_Action_Vector2 leftFootInput = SteamVR_Input.GetAction<SteamVR_Action_Vector2>("joystick");//moving
    public SteamVR_Action_Pose poseAction = SteamVR_Input.GetAction<SteamVR_Action_Pose>("Pose");//rotating
    public SteamVR_Action_Vibration hptc = SteamVR_Input.GetAction<SteamVR_Action_Vibration>("haptic");//haptic feedback 
    public SteamVR_Action_Vibration isCanRotate = SteamVR_Input.GetAction<SteamVR_Action_Vibration>("canrotate");//can(not) rotate
    

Input - movement

  1. You could use the following code to get the XY axis input when tilting left, right, forward, or backward on the Hoverboard to move your avatar in the game

    Vector2 vector2 = leftFootInput.GetAxis(SteamVR_Input_Sources.LeftFoot);
    m_kMoveObj.position += (m_kMoveObj.right * vector2.x + m_kMoveObj.forward * vector2.y) * 10f * Time.deltaTime;
    

Input - rotation

  1. You could use the following code to get your real-time rotation input on the Hoverboard

    Quaternion qu = poseAction[SteamVR_Input_Sources.LeftFoot].localRotation;
    Vector3 v3temp = qu.eulerAngles;
    m_kMoveObj.rotation = Quaternion.Lerp(m_kMoveObj.rotation, Quaternion.Euler(Vector3.up * (v3temp.y % 360)), 100 * Time.deltaTime);
    //supplementary angles
    Vector3 localEulerAngles = m_kMoveObj.GetChild(0).localEulerAngles;
    localEulerAngles.y = -(v3temp.y % 360f);
    m_kMoveObj.GetChild(0).localEulerAngles = localEulerAngles;
    

Output - haptic(currently not supported)

  1. You could use the following code to enable/disable haptic feedback output. Note that (0,0,0,1) is enable and (0,0,0,0) is disable

    hptc.Execute(0, 0, 0, Random.value, SteamVR_Input_Sources.LeftFoot);
    

Output - rotation

  1. You could use the following code to enable/disable rotation output. Note that (0,0,0,0) is enable and (0,0,0,1) is disable

    isCanRotate.Execute(0, 0, 0, 0, SteamVR_Input_Sources.LeftFoot);
    

What’s next:

Sample Project Download