Skip to content

Sample Code

Cory Corvus edited this page May 19, 2020 · 9 revisions

Unity Sample Code

Detect VR HMD and controller

Link

Reset head position

Link

Detect system button press (SteamVR Overlay) and enable/disable gameobject

Link

Get VIVE controller trigger full down/click

Link

Simple Laser Pointer

Link

Move objects to hand's position

Link

Power off SteamVR device

Link

VR Player Controller

Link

Video Tutorial

Subscribe to Action (SteamVR 2.x)

public void SubscribeToPlayerAction(SteamVR_Action_Boolean action, SteamVR_Action_Boolean.ChangeHandler onAction)
{
    action.AddOnChangeListener(onAction, SteamInputSource); //SteamInputSource can be Left Right or Any
}

Poll Action (SteamVR 2.x)

public bool CheckForPlayerAction(SteamVR_Action_Boolean action, ButtonAction buttonState = ButtonAction.PressDown)
{
    if (buttonState == ButtonAction.PressDown) return action.GetStateDown(SteamInputSource);
    if(buttonState == ButtonAction.IsPressed) return action.GetState(SteamInputSource);

    return action.GetStateUp(SteamInputSource);
}

Unreal Engine Sample Code

VIVE Tracker without HMD in Unreal Engine

Link

Clone this wiki locally