123456789101112131415161718192021222324252627 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- /// <summary>
- /// 相机漫游是否穿碰撞器判断
- /// </summary>
- public class CameraRestraint : MonoBehaviour
- {
- private static RaycastHit _hit;
- /// <summary>
- /// 球形射线检测相机是否即将穿过碰撞器
- /// </summary>
- /// <param name="camera"></param>
- /// <param name="pos"></param>
- /// <returns></returns>
- 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;
- }
- }
|