【发布时间】:2020-08-19 12:27:45
【问题描述】:
我已经创建了一个从 1 到 0 的 PingPong 助手,但我很难将其反转,因此值从 1 变为 0。
您可以在下面看到代码,我目前正在使用。我也不确定这是否可能。
_lerpPulse = PingPong(Time.time * 0.5f, 0f, 1f);
还有帮手
float PingPong(float aValue, float aMin, float aMax)
{
return Mathf.PingPong(aValue, aMax - aMin) + aMin;
}
提前致谢!
【问题讨论】:
-
为什么不直接使用 sin / cos 函数呢?顺便说一句,
+ aMin不是必需的 -
我最初使用的是 Sin,但不知道如何从 1 变为 0 _lerpPulse = (Mathf.Sin(Time.time * 2f) + 1f) / 2f 这是正在使用的和适用于 0 到 1
标签: c# unity3d lerp math-functions