在统一中,如何在缓慢的帧速率中保持平稳运动?

发布于 2025-02-12 02:37:48 字数 1148 浏览 2 评论 0 原文

当目标帧速率大于30时,就可以了。动作很好,游戏是可以玩的。但是,当事情发生在10-20目标框架速率时,就无法得到我想要的。结果是矮胖且无法播放的。因此,我的问题是这个问题。

Unity的自我LERP功能现在无法正常工作。 好吧,它有效,但结果不是我想要的。事情仍然很卑鄙。

我在我的代码中将“ target framerate”值分配给“ application.targetFramerate”

我试图为此使用Kalman Filter。结果好一些,但没有更接近我的期望。 过滤值:

      float filteredX = kalmanFilterFloat.Update(p.value.x);
      float filteredY = kalmanFilterFloat.Update(p.value.y);
      float filteredZ = kalmanFilterFloat.Update(p.value.z);

此处即时模拟污点LERP:

  private void SimulateFilteredLerp(InterpolatedProperty<Vector3> p, Vector3 filteredVec) 
  {
    p.prevValue = p.value = Vector3.Lerp(p.value + new Vector3(filteredVec.x,
    filteredVec.y, filteredVec.z) * masterClock.delta, p.target, masterClock.delta * settings.interpolationSnapping);
  }

应用过滤的向量:

      Vector3 filteredVec = new Vector3((float)filteredX, (float)filteredY, (float)filteredZ);

更新中的调用函数

      SimulateFilteredLerp(p, filteredVec);

When the target frame rate is greater than 30, its okay. Movements are good and the game is playable. But when the things going like 10-20 target frame rate, it's not getting what I want. The result is laggy and unplayable. So basicly my question is this.

Unity's self Lerp function isn't working right now.
Well, its working but the result is not what I want. Still the things are laggy.

Im assigning "TargetFrameRate" value to "Application.targetFrameRate" in my code somewhere
From Inspector Show

I tried to use Kalman Filter for this. The result a little bit better but no so quite closer to what I expect.
Filtered Values:

      float filteredX = kalmanFilterFloat.Update(p.value.x);
      float filteredY = kalmanFilterFloat.Update(p.value.y);
      float filteredZ = kalmanFilterFloat.Update(p.value.z);

Here im simulating filtired lerp:

  private void SimulateFilteredLerp(InterpolatedProperty<Vector3> p, Vector3 filteredVec) 
  {
    p.prevValue = p.value = Vector3.Lerp(p.value + new Vector3(filteredVec.x,
    filteredVec.y, filteredVec.z) * masterClock.delta, p.target, masterClock.delta * settings.interpolationSnapping);
  }

Applying filtered vector:

      Vector3 filteredVec = new Vector3((float)filteredX, (float)filteredY, (float)filteredZ);

Calling function in Update

      SimulateFilteredLerp(p, filteredVec);

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文