using System.Collections; using System.Collections.Generic; using UnityEngine; public class Point : MonoBehaviour { public Transform uiRoot; public Transform canvas; public Transform target; //旋转距离 public float targetDistance = 2.0f; //是否到达旋转的距离 private bool arriveDistance = false; private void Update() { if (arriveDistance) { transform.RotateAround(target.position, Vector3.up, Time.deltaTime * 20); transform.LookAt(target); } else { float distance = Vector3.Distance(transform.position, target.position); if (distance <= targetDistance) { arriveDistance = true; } else { transform.position = Vector3.Lerp(transform.position, target.position, Time.deltaTime); arriveDistance = false; } } } }