123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class QiuMove : MonoBehaviour
- {
- float zMoveMax = 10;
- float xMoveMax = 16;
- public float zMoveMaxNow = 6;
- public float xMoveMaxNow = 9;
- // Start is called before the first frame update
- void Start()
- {
-
- }
- // Update is called once per frame
- void Update()
- {
- float xx = -OpenXRCamera.Instance.head.transform.position.x* (xMoveMax / xMoveMaxNow)+10.2f;
- if(Mathf.Abs(xx) >xMoveMax)
- {
- if(xx < 0)
- {
- xx = -xMoveMax;
- }
- else
- {
- xx = xMoveMax;
- }
- }
- float zz = -OpenXRCamera.Instance.head.transform.position.z * (zMoveMax / zMoveMaxNow);
- if (Mathf.Abs(zz) > zMoveMax)
- {
- if (zz < 0)
- {
- zz = -zMoveMax;
- }
- else
- {
- zz = zMoveMax;
- }
- }
- this.transform.localPosition = new Vector3(xx,-7, zz);
- this.transform.localEulerAngles = new Vector3(0,OpenXRCamera.Instance.head.transform.eulerAngles.y,0);
- }
- }
|