Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 照明亮度的Lerp不是逐渐增加的_C#_Unity3d_Coroutine_Ienumerator - Fatal编程技术网

C# 照明亮度的Lerp不是逐渐增加的

C# 照明亮度的Lerp不是逐渐增加的,c#,unity3d,coroutine,ienumerator,C#,Unity3d,Coroutine,Ienumerator,我对Lerp的实现应该随着时间的推移逐渐将灯光从minbrightness增加到maxBrightness。它确实改变了我的灯光范围,但是它会立即转到我的maxBrightness,而不是逐渐增加。我哪里出错了 以下是我正在使用的代码 private void Update() { //this is a timer that will only only count down when collided = true if (_collided == true) {

我对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;
    }
}
private void Update()
{
//这是一个计时器,只有当Collide=true时才会倒计时
如果(_collide==true)
{
timeLeft-=Time.deltaTime;
_light1.range=Mathf.Lerp(最小亮度、最大亮度、lightTimer);
//增加闯入者
lightTimer+=\u BrightRate*Time.deltaTime;
}
其他的
{
//这将灯光范围值设置为大于正常值
_light1.range=Mathf.Lerp(最大亮度、最小亮度、lightTimer);
//增加闯入者
lightTimer+=\u BrightRate*Time.deltaTime;
}
//检查时间值是否为0

如果(timeLeft在我看来很好。你的
\u brightRate
值可能太大。如果它是一个序列化字段(如果你使用
[SerializeField]
和/或
public
),如果你没有在代码中的某个地方设置它,请确保你在检查器中设置它。@Ruzihm\u brightRate是0.5f