AttachBikeToHead.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using UnityEngine.XR;
  6. using Valve.VR;
  7. public class AttachBikeToHead : MonoBehaviour
  8. {
  9. public Transform playerTransform;
  10. public Transform cameraTransform;
  11. public Transform bikeTransform;
  12. public float headHeihgt = 1.4f;
  13. public SteamVR_Action_Boolean resetAction;
  14. private SteamVR_Render render;
  15. private float initialBikeY;
  16. // Start is called before the first frame update
  17. void Start()
  18. {
  19. render = FindObjectOfType<SteamVR_Render>();
  20. //initialBikeY = bikeTransform.position.y;
  21. ResetPositionAndRotation();
  22. }
  23. private void ResetPositionAndRotation()
  24. {
  25. //bikeTransform.position = new Vector3(playerTransform.position.x, initialBikeY, playerTransform.position.z);
  26. //bikeTransform.rotation = playerTransform.rotation;
  27. //resetAction.AddOnStateUpListener(OnStateUp, SteamVR_Input_Sources.Any);
  28. //playerTransform.localPosition = new Vector3(0f, 1.32f, -0.8f);
  29. //playerTransform.localRotation = Quaternion.Euler(Vector3.zero);
  30. //cameraTransform.position = playerTransform.position;
  31. //cameraTransform.rotation = playerTransform.rotation;
  32. }
  33. private void OnStateUp(SteamVR_Action_Boolean fromAction, SteamVR_Input_Sources fromSource)
  34. {
  35. ResetPositionAndRotation();
  36. }
  37. }