Hi.
I’m trying to create a script that will move an object (trigger) between 2 local positions: 0,0,0 and 0,0,(0.01f), but I can only get access to VR Vive controller trigger as if it was a button:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class FN_Trigger : MonoBehaviour
{
private SteamVR_TrackedObject trackedObject;
private SteamVR_Controller.Device device;
// Use this for initialization
void Start()
{
GameObject RController = GameObject.Find("Controller (right)");
trackedObject = RController.GetComponent<SteamVR_TrackedObject>();
device = SteamVR_Controller.Input((int)trackedObject.index);
transform.localPosition = new Vector3(0, 0, 0);
}
// Update is called once per frame
void Update()
{
if (device.GetPressDown(SteamVR_Controller.ButtonMask.Trigger))
{
device.TriggerHapticPulse(10000);
transform.localPosition = new Vector3(0, 0, 0.01f);
}
if (device.GetPressUp(SteamVR_Controller.ButtonMask.Trigger))
{
transform.localPosition = new Vector3(0, 0, 0);
}
}
}
How can I access its axis reading and use it to move my object over with it?