修曲线

This commit is contained in:
2025-10-06 15:59:37 +08:00
parent 286c91579f
commit 627c4c95dd
3 changed files with 7 additions and 2 deletions

View File

@@ -173,7 +173,12 @@ namespace ArachnaeSwarm
// 1. Generate Bezier curve points
int segments = Mathf.Max(3, Mathf.CeilToInt(magnitude * Props.flecksPerCell));
Vector3 controlPoint = Vector3.Lerp(start, end, 0.5f) + new Vector3(0, -magnitude * Props.beamCurvature, 0);
// --- ULTIMATE CURVE FIX ---
// The control point must be offset perpendicular to the beam's direction on the XZ plane, not on the Y axis.
Vector3 direction = (end - start).normalized;
Vector3 perpendicular = new Vector3(-direction.z, 0, direction.x); // Rotated 90 degrees on the XZ plane.
Vector3 controlPoint = Vector3.Lerp(start, end, 0.5f) + perpendicular * magnitude * Props.beamCurvature;
var path = BezierUtil.GenerateQuadraticPoints(start, controlPoint, end, segments);
// 2. Check if there are enough points to connect
if (path.Count < 2)