feat(skill): add movement acceleration support for skills
1. 新增SMoveComp的isAccelerate字段控制加速逻辑 2. 添加技能配置is_accel字段启用加速效果 3. 实现二次方缓入加速曲线,兼顾起步速度与最终加速度 4. 为6001号技能默认开启加速效果并调整其移动类型为直线运动
This commit is contained in:
@@ -40,10 +40,13 @@ export class SMoveSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate
|
||||
return;
|
||||
}
|
||||
|
||||
// 根据配置设置移动速度
|
||||
// 根据配置设置移动速度与加速度
|
||||
if (skillConfig.speed > 0) {
|
||||
moveComp.speed = skillConfig.speed;
|
||||
}
|
||||
if (skillConfig.is_accel) {
|
||||
moveComp.isAccelerate = true;
|
||||
}
|
||||
|
||||
// 根据runType设置初始位置
|
||||
this.initializePosition(moveComp, skillView);
|
||||
@@ -190,10 +193,12 @@ export class SMoveSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate
|
||||
if (moveComp.progress < 1) {
|
||||
// 计算下一帧的位置来确定方向
|
||||
const nextProgress = Math.min(moveComp.progress + 0.01, 1);
|
||||
const t = moveComp.isAccelerate ?
|
||||
(nextProgress * nextProgress * 0.7 + nextProgress * 0.3) :
|
||||
nextProgress;
|
||||
const nextPos = v3(0, 0, 0);
|
||||
|
||||
// 计算下一个位置
|
||||
const t = nextProgress;
|
||||
const oneMinusT = 1 - t;
|
||||
const oneMinusTSquared = oneMinusT * oneMinusT;
|
||||
const tSquared = t * t;
|
||||
@@ -245,6 +250,7 @@ export class SMoveHelper {
|
||||
if (skillConfig) {
|
||||
moveComp.runType = skillConfig.RType || RType.linear;
|
||||
moveComp.speed = skillConfig.speed || 500;
|
||||
if (skillConfig.is_accel) moveComp.isAccelerate = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user