public static Vector2 NearestPointOnFiniteLine(Vector2 start, Vector2 end, Vector2 pnt) { var line = (end - start); var len = Mathf.Sqrt(line.X * line.X + line.Y * line.Y); line = line.Normalized; var v = pnt - start; var d = Vector2.Dot(v, line); d = Mathf.Clamp(d, 0f, len); return(start + line * d); }
private bool IsInsideHitbox(Vector2 pos) { var num = Vector2.DistanceSquared(ClosestPoint, pos); var num2 = LocalPlayer.Instance.MapCollision.MapCollisionRadius + Data.Radius; if (num <= num2 * num2) { var normalized = (DashObject.TargetPosition - DashObject.StartPosition).Normalized; var value = pos + normalized * Data.Radius; if (Vector2.Dot(normalized, value - DashObject.StartPosition) > 0f) { return(true); } } return(false); }