c# - 照明亮度的 Lerp 不会逐渐增加
问题描述
minbrightness
我的 Lerp 实现应该随着时间的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
,但不确定如何将它应用到我当前的解决方案中,或者这是否能解决我当前的问题。
解决方案
推荐阅读
- javascript - node.js - 从异步函数推送到数组
- scala - 一个专门的参数类/特征可以扩展另一个特征吗?
- android - 我已将我的 Google API 密钥限制为我的移动应用程序包。还能被盗吗?
- java - Spring-boot:应用程序无法启动
- java - 控制面板和终端之间的 Java 版本不匹配
- javascript - 在类成员函数中使用常量变量的最快方法?
- html - 日期字段的占位符 Asp.net HtmlHelper
- javascript - 如何使用 html 和 javascript 中的输入更改连接多个 id 以更改颜色
- user-interface - ListTile 中的图像
- swagger - 带有 OdataQueryOptions 的 WebApi 方法在 swagger 文档中未正确显示