12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class HeadPos : MonoBehaviour
- {
- public Transform head;
- public Transform uiRoot;
- public Transform leftObj;
- public Transform rightObj;
- private UIMove uiMove;
- private void Start()
- {
- uiMove = uiRoot.GetComponent<UIMove>();
- }
- void Update()
- {
- transform.position = head.position;
- transform.eulerAngles = new Vector3(0, head.eulerAngles.y, 0);
-
- //if (uiMove.isMove)
- //{
- // //uiRoot.eulerAngles = transform.eulerAngles;
- // float dis = Vector2.Distance(new Vector2(transform.GetChild(0).position.x, transform.GetChild(0).position.z), new Vector2(uiRoot.position.x, uiRoot.position.z));
- // Debug.Log(dis);
- // if (Mathf.Abs(dis) > 0.6f)
- // {
- // float disleft = Vector3.Distance(uiRoot.position, leftObj.position);
- // float disright = Vector3.Distance(uiRoot.position, rightObj.position);
- // if (Mathf.Abs(disleft) > Mathf.Abs(disright))
- // {
- // // uiRoot.position = new Vector3(rightObj.position.x, -0.3f, rightObj.position.z);
- // uiRoot.RotateAround(transform.position, Vector3.up, -1);
- // //if(Mathf.Abs(dis) > 0.7f)
- // // uiRoot.position = new Vector3(rightObj.position.x, -0.3f, rightObj.position.z);
- // }
- // else
- // {
- // // uiRoot.position = new Vector3(leftObj.position.x, -0.3f, leftObj.position.z);
- // uiRoot.RotateAround(transform.position, Vector3.up, 1);
- // //if (Mathf.Abs(dis) > 0.7f)
- // // uiRoot.position = new Vector3(leftObj.position.x, -0.3f, leftObj.position.z);
- // }
- // }
- // //float y = (transform.eulerAngles.y - uiRoot.eulerAngles.y);
- // //Debug.Log(y);
- // //if (y > 10)
- // //{
- // // uiRoot.RotateAround(transform.position, Vector3.up, y);
- // //}
- // //else if (y < -30 )
- // //{
- // // uiRoot.RotateAround(transform.position, Vector3.up, transform.eulerAngles.y - 30);
- // //}
- //}
- }
- }
|