ViveInput.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using Valve.VR;
  5. public class ViveInput : MonoBehaviour
  6. {
  7. public PlayerReplay playerReplay;
  8. private SteamVR_Action_Boolean grabPinch;
  9. private SteamVR_Action_Boolean grabGrib;
  10. private SteamVR_Action_Boolean teleport;
  11. private bool isRecording;
  12. private float recordingTime;
  13. private void Start()
  14. {
  15. grabPinch = SteamVR_Actions.default_GrabPinch;
  16. grabGrib = SteamVR_Actions.default_GrabGrip;
  17. teleport = SteamVR_Actions.default_Teleport;
  18. }
  19. void Update()
  20. {
  21. if (grabPinch.GetStateDown(SteamVR_Input_Sources.Any))
  22. {
  23. //playerReplay.AddJoints();
  24. isRecording = true;
  25. }
  26. if (teleport.GetStateDown(SteamVR_Input_Sources.Any))
  27. {
  28. isRecording = false;
  29. recordingTime = 0;
  30. playerReplay.Save();
  31. }
  32. if (grabGrib.GetStateDown(SteamVR_Input_Sources.Any))
  33. {
  34. playerReplay.Load();
  35. }
  36. if (isRecording)
  37. {
  38. playerReplay.AddJoints(recordingTime);
  39. recordingTime += Time.deltaTime;
  40. }
  41. }
  42. }