using System.Collections; using System.Collections.Generic; using NRKernal; using UnityEngine; public class followrotation : MonoBehaviour { public GameObject Reboot; public float bfloatx; public int nowindex; public GameObject head; public List endList; bool isa; bool isp; public GameObject fgo; private void Start() { // fgo = Reboot; nowindex = endList.Count-1; yidong(); } public void yidong() { // return; if(endList.Count> nowindex) { Vector3 v3 = endList[nowindex].transform.position - OpenXRCamera.Instance.head.transform.localPosition; head.transform.position = new Vector3(v3.x, OpenXRCamera.Instance.head.transform.position.y, v3.z); } nowindex++; isa = false; isp = false; // Debug.Log("yidong==="); } // Update is called once per frame void Update() { if(Input.GetKeyDown(KeyCode.O)) { yidong(); } // Pose poseInAPIWorld = new Pose(NRInput.GetPosition(ControllerHandEnum.Right), NRInput.GetRotation(ControllerHandEnum.Right)); // Pose pose = ApplyWorldMatrix(poseInAPIWorld); // transform.position = Vector3.zero;// NRInput.CameraCenter.TransformPoint(m_DefaultLocalOffset); // transform.rotation = pose.rotation; this.transform.localEulerAngles = fgo.transform.localEulerAngles; float xx = this.transform.localEulerAngles.x; if (this.transform.localEulerAngles.x>180) { xx= this.transform.localEulerAngles.x - 360f ; } if(!isa) { if((xx) > 10) { isa = true; bfloatx = xx; } // Debug.Log("yidong==1="+ (xx)); } if(!isp&& isa) { if ((bfloatx-20)> (xx)) { isa = false; yidong(); } // Debug.Log((xx) +"=====yidong==2=" + (bfloatx - 40)); } } private Matrix4x4 m_CachedWorldMatrix = Matrix4x4.identity; /// Apply world transform. private Pose ApplyWorldMatrix(Pose pose) { var objectMatrix = ConversionUtility.GetTMatrix(pose.position, pose.rotation); var object_in_world = m_CachedWorldMatrix * objectMatrix; return new Pose(ConversionUtility.GetPositionFromTMatrix(object_in_world), ConversionUtility.GetRotationFromTMatrix(object_in_world)); } }