问题描述
我的 Lerp 实现应该随着时间的推移逐渐将光从 minbrightness
增加到 maxBrightness
。它确实改变了我的光的范围,但它会立即进入我的 maxBrightness
而不是逐渐增加。我哪里出错了?
这是我使用的代码
private void Update()
{
//this is a timer that will only only count down when collided = true
if (_collided == true)
{
timeLeft -= Time.deltaTime;
_light1.range = Mathf.Lerp(minbrightness,maxBrightness,lightTimer);
//increases interloper
lightTimer += _brightenRate * Time.deltaTime;
}
else
{
//this sets the lights range value to be bigger then normal
_light1.range = Mathf.Lerp(maxBrightness,minbrightness,lightTimer);
//increases interloper
lightTimer += _brightenRate * Time.deltaTime;
}
//checks if the time value is 0
if (timeLeft <= 0)
{
//this resets the value back
timeLeft = timeLeftReset;
_collided = false;
}
}
我听说过 IEnumerator
,但不确定如何将其应用于我当前的解决方案,或者这是否能解决我当前的问题。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)