判断物体是否在视野范围内 判断物体是否在视野内是个简单的算法,这个判断是判断点的中心点坐标,而不是判断是否渲染。 [C#] 纯文本查看 复制代码 ? 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 using UnityEngine; using System.Collections; public class VisibilityChecker : MonoBehaviour { public bool visible { get { Camera tmpCam = Camera.main; if (tmpCam) { return Vector3.Angle((transform.position - tmpCam.transform.position).normalized, tmpCam.transform.forward.normalized) < tmpCam.fieldOfView; } return false ; } } void Update() { print(visible); } } 代码简单,不解释了