From c1da9e8a6bb1dbc4cc79be2cdd77e67190c20a71 Mon Sep 17 00:00:00 2001 From: Lenheart <947330670@qq.com> Date: Tue, 17 Dec 2024 21:45:27 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=95=B0=E6=8D=AE=E5=BA=93?= =?UTF-8?q?=E7=9A=84sq=5FGetAccel?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sqr/Core/BaseTool/Math.nut | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/sqr/Core/BaseTool/Math.nut b/sqr/Core/BaseTool/Math.nut index 3a4ae83..d6df687 100644 --- a/sqr/Core/BaseTool/Math.nut +++ b/sqr/Core/BaseTool/Math.nut @@ -319,20 +319,19 @@ class Math { } function sq_GetAccel(sv, ev, currentRate, maxRate, increaseFeature) { - local rate = currentRate.tofloat() / maxRate.tofloat(); - local varyValue = ev - sv; local increaseRate = 1.0; - if (increaseFeature) { increaseRate = pow(50, rate) / 50; //慢->快 } else { - increaseRate = pow(rate, 0.05); + // 修正后的减速逻辑计算,例如采用线性变换结合幂次运算来实现更合理的减速效果 + // 先将rate映射到一个更合适的范围(这里从[0,1]映射到[0.1, 1],可调整) + local mappedRate = rate * 0.9 + 0.1; + increaseRate = pow(mappedRate, 2); // 幂次可调整,这里取2来让减速更明显,可根据实际情况修改 } - return sv + varyValue * increaseRate; }