我想在 Update 方法中每 1 秒从设定值中消耗健康值。我写了代码,但它似乎耗尽的速度超过 1 秒。
在 Update 方法中,我调用:
if (Hunger <= 0.0f)
{
userHealth -= HealthDepletionValue * Time.deltaTime;
}
Run Code Online (Sandbox Code Playgroud)
这应该消耗的设定值HealthDepletionValue每秒Time.deltaTime。
当我运行游戏时,它会每 0.1 秒或类似的时间消耗HealthDepletionValue。但肯定不是每 1 秒一次,就像我想要的那样。
我错过了什么?