QiuMove.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class QiuMove : MonoBehaviour
  5. {
  6. float zMoveMax = 10;
  7. float xMoveMax = 16;
  8. public float zMoveMaxNow = 6;
  9. public float xMoveMaxNow = 9;
  10. // Start is called before the first frame update
  11. void Start()
  12. {
  13. }
  14. // Update is called once per frame
  15. void Update()
  16. {
  17. float xx = -OpenXRCamera.Instance.head.transform.position.x* (xMoveMax / xMoveMaxNow)+10.2f;
  18. if(Mathf.Abs(xx) >xMoveMax)
  19. {
  20. if(xx < 0)
  21. {
  22. xx = -xMoveMax;
  23. }
  24. else
  25. {
  26. xx = xMoveMax;
  27. }
  28. }
  29. float zz = -OpenXRCamera.Instance.head.transform.position.z * (zMoveMax / zMoveMaxNow);
  30. if (Mathf.Abs(zz) > zMoveMax)
  31. {
  32. if (zz < 0)
  33. {
  34. zz = -zMoveMax;
  35. }
  36. else
  37. {
  38. zz = zMoveMax;
  39. }
  40. }
  41. this.transform.localPosition = new Vector3(xx,-7, zz);
  42. this.transform.localEulerAngles = new Vector3(0,OpenXRCamera.Instance.head.transform.eulerAngles.y,0);
  43. }
  44. }