fix(skill): 优化移动系统:简化飞行逻辑

重构移动系统

调整技能移动的朝向和目标点计算逻辑,改为仅按水平朝向飞行,移除基于缩放的固定水平移动,去掉高度差计算,简化目标点直接使用起始点高度。
This commit is contained in:
panFD
2026-08-15 16:23:12 +08:00
parent ac2e849821
commit 42c0a25e20

View File

@@ -74,42 +74,24 @@ export class SMoveSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate
moveComp.startPos.z
);
const originTargetPos = v3(
moveComp.targetPos.x,
moveComp.targetPos.y,
moveComp.targetPos.z
);
const direction = new Vec3();
Vec3.subtract(direction, originTargetPos, adjustedStartPos);
// 水平向前飞行方向仅由朝向scale决定忽略目标点的高度差
const forwardX = moveComp.scale > 0 ? 1 : -1;
let adjustedTargetPos: Vec3;
if (moveComp.distance > 0) {
// 距离模式:沿起始指向目标的方向飞行固定距离
if (direction.length() < 0.01) {
// 起终点重合时退化为按朝向水平飞行
direction.set(moveComp.scale > 0 ? 1 : -1, 0, 0);
}
direction.normalize();
// 距离模式:沿水平方向飞行固定距离
adjustedTargetPos = v3(
adjustedStartPos.x + direction.x * moveComp.distance,
adjustedStartPos.y + direction.y * moveComp.distance,
originTargetPos.z
adjustedStartPos.x + forwardX * moveComp.distance,
adjustedStartPos.y,
adjustedStartPos.z
);
} else {
// 延长终止点统一消亡点的x坐标为 +-500
const targetX = moveComp.scale > 0 ? 500 : -500;
let targetY = originTargetPos.y;
if (Math.abs(direction.x) > 0.01) {
const slope = direction.y / direction.x;
targetY = adjustedStartPos.y + slope * (targetX - adjustedStartPos.x);
}
adjustedTargetPos = v3(
targetX,
targetY,
originTargetPos.z
adjustedStartPos.y,
adjustedStartPos.z
);
}