using System.Collections; using System.Collections.Generic; using UnityEngine; public class UILookAtHead : MonoBehaviour { void Start () { } void Update () { } private Vector3 dir; private void LateUpdate() { if(LookTarget == null) { return; } //this.transform.LookAt(LookTarget, -Vector3.forward); dir = LookTarget.position - this.transform.position; //dir.x =dir.z = 0; //dir.y = 0; if(dir.Equals(Vector3.zero)) { return;//排除掉0 } //this.transform.rotation = Quaternion.LookRotation(dir, Vector3.up); //dir = this.transform.eulerAngles; //dir.y = 0; //this.transform.eulerAngles = dir; this.transform.LookAt(LookTarget); } private Transform LookTarget { get { return SvrManager.Instance.head.transform; //return Camera.main.transform; } } }