1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using Valve.VR;
- public class ViveInput : MonoBehaviour
- {
- public PlayerReplay playerReplay;
- private SteamVR_Action_Boolean grabPinch;
- private SteamVR_Action_Boolean grabGrib;
- private SteamVR_Action_Boolean teleport;
- private bool isRecording;
- private float recordingTime;
- private void Start()
- {
- grabPinch = SteamVR_Actions.default_GrabPinch;
- grabGrib = SteamVR_Actions.default_GrabGrip;
- teleport = SteamVR_Actions.default_Teleport;
- }
- void Update()
- {
- if (grabPinch.GetStateDown(SteamVR_Input_Sources.Any))
- {
- //playerReplay.AddJoints();
- isRecording = true;
- }
- if (teleport.GetStateDown(SteamVR_Input_Sources.Any))
- {
- isRecording = false;
- recordingTime = 0;
- playerReplay.Save();
- }
- if (grabGrib.GetStateDown(SteamVR_Input_Sources.Any))
- {
- playerReplay.Load();
- }
- if (isRecording)
- {
- playerReplay.AddJoints(recordingTime);
- recordingTime += Time.deltaTime;
- }
- }
- }
|