Skip to content

Instantly share code, notes, and snippets.

@davepape
Last active November 1, 2021 13:38
Show Gist options
  • Save davepape/e61d1f077a3a6d7ea7f48820b01f31fb to your computer and use it in GitHub Desktop.
Save davepape/e61d1f077a3a6d7ea7f48820b01f31fb to your computer and use it in GitHub Desktop.
simple steamvr navigator
// Super-simple navigation for SteamVR. Attach this script to a Unity GameObject, and make the SteamVR CameraRig a child of that object.
// Travels in the direction that the left controller is pointing, speed scaled by how much the trigger is pulled.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Valve.VR;
public class Navigator : MonoBehaviour
{
public float speed = 0.1f;
void Start()
{
}
void Update()
{
Vector3 dir = SteamVR_Actions._default.Pose[SteamVR_Input_Sources.LeftHand].localRotation * Vector3.forward;
transform.localPosition += dir * speed * SteamVR_Actions._default.Squeeze[SteamVR_Input_Sources.LeftHand].axis;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment