小编Art*_*kin的帖子

在 Update 方法中每 X 秒消耗一次设定值

我想在 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 秒一次,就像我想要的那样。

我错过了什么?

c# unity-game-engine

0
推荐指数
1
解决办法
110
查看次数

标签 统计

c# ×1

unity-game-engine ×1