Unity3d 动态 FOV 脚本导致错误:“std::abs(det) > FLT_MIN”

问题描述 投票:0回答:0

关于这个错误,我唯一知道的是用户 CrimsonFreak 在一个类似的问题中告诉我的:“错误的字面意思是,无论 det 是什么,它的绝对值并不优于统一系统中的 FLT_MIN代码。” (顺便说一句,非常感谢<3). The error seems to appear when the velocity of the player changes too quickly, for example when crashing into another object at high enough speeds. I solved it temporarily by changing the bounciness of the Physics Material to 0, but now the error is back and I managed to single out that the error is caused by my dynamic FOV, here's that code:

void Update()
{
    if (playerPosition == null)
    {
        return;
    }

    else
    {
        gameObject.GetComponent<Camera>().fieldOfView = newFieldOfView();
    }
}

private float newFieldOfView()
{
    float speed = player.GetComponent<Rigidbody>().velocity.z + 6;
    float targetFOV = (float)Math.Log(speed, 1.1) + 34;

    return (Mathf.Lerp(GetComponent<Camera>().fieldOfView, targetFOV, (float)0.1));
}

所以我的问题是:为什么这会混淆引擎?我尝试将其更改为 FixedUpdate() 函数,但这并没有改变任何东西。此外,任何解决方案/其他方法来制作简单的动态 FOV 的建议当然会非常感激。提前感谢大家的帮助:)

c# unity3d
© www.soinside.com 2019 - 2024. All rights reserved.