using System.Collections; using System.Collections.Generic; using UnityEngine; /// /// 相机漫游是否穿碰撞器判断 /// public class CameraRestraint : MonoBehaviour { private static RaycastHit _hit; /// /// 球形射线检测相机是否即将穿过碰撞器 /// /// /// /// public static bool CheckThePos(Transform camera,Vector3 pos) { if (Physics.SphereCast(camera.position,0.5f,(pos-camera.position).normalized,out _hit ,0.3f)) { if (_hit.transform.CompareTag("DontCross")) return true; else return false; } return true; } }