public override bool IsTouch(ActorBase actor) { if (actor == null || actor.CachedTransform == null) { return(false); } if (Radius <= 0) { return(false); } if (GlobalTools.GetHorizontalDistance(Center.position, actor.Pos) < actor.Radius) { return(true); } return(false); }
public float Height = 2; //圆柱有效高度 public override bool IsTouch(ActorBase actor) { if (actor == null || actor.CachedTransform == null) { return(false); } if (HAngle <= 0 || Height <= 0) { return(false); } float y = Center.position.y; float yMax = y + Height / 2; float yMin = y - Height / 2; if (actor.Pos.y + actor.Height <= yMin) { return(false); } if (actor.Pos.y >= yMax) { return(false); } Vector3 dirPos = Euler + Center.forward; dirPos.y = 0; float radius = MaxDis + actor.Radius; if (GlobalTools.GetHorizontalDistance(Center.position, actor.Pos) > radius) { return(false); } Vector3 targetPos = actor.Pos; targetPos.y = 0; Vector3 centerPos = Center.position; centerPos.y = 0; if (Vector3.Angle(targetPos - centerPos, dirPos) > HAngle / 2) { return(false); } return(true); }