static public class CameraMove{...}
///
/// 射线检测:障碍穿越
///
/// 射线发射原点
/// 射线发射向量
/// 二次延伸长度
/// 遮罩层:~LayerMask.GetMask(Tags.player)//忽略player
/// return : 穿越后的位置
static public Vector3 Obstacle_crossing(Vector3 origin, Vector3 direction,float collision_distance,int LayerMask){
RaycastHit hit;
Vector3 directionExtended = direction + direction.normalized*collision_distance;//向量延伸
if(Physics.Raycast(origin,directionExtended,out hit,directionExtended.magnitude,LayerMask)){
return hit.point-(direction.normalized*collision_distance);//前往射线碰撞位置
}else{
return origin+direction;//回到原始位置
}
}