在Amethyst或许多其他游戏引擎中,逻辑的update和呈现的fixed_update是有区别的。
Bevy 0.4引入了状态,但是只有enter、update和exit生命周期挂钩。可以使用来自stage模块的常量来创建自定义阶段,但它只添加了POST_UPDATE和PRE_UPDATE。
我的问题在标题中,但如果没有相应的内容,是否有最佳做法来运行处理呈现的系统?
一个可行的解决方案是创建第二个更新系统(例如,render ),但是,如果有更好的方法,我的目标是提高性能。
发布于 2021-01-02 17:35:37
我不知道这对于您的用例是否有帮助,但是在贝维0.4宣布中,这个例子显示了用FixedTimestep创建一个阶段是可能的。
因此,使用0.4公告中的示例作为基础:
use bevy::prelude::*;
use bevy::core::FixedTimestep;
fn main() {
let target_rate = 60.0;
App::build()
// Add the default plugins to open a window
.add_plugins(DefaultPlugins)
.add_stage_after(
stage::UPDATE,
"fixed_update",
SystemStage::parallel()
// Set the stage criteria to run the system at the target
// rate per seconds
.with_run_criteria(FixedTimestep::steps_per_second(target_rate))
.with_system(my_system.system()),
)
.run();
}也许这种方法没有得到优化(我不太清楚FixedTimestep标准在内部是如何工作的),但在大多数情况下应该足够了。
编辑
我发现使用渲染应用程序阶段作为艺名是可能的,它应该更符合您的需要:
use bevy::prelude::*;
fn main() {
App::build()
// Add the default plugins to open a window
.add_plugins(DefaultPlugins)
.add_system_to_stage(bevy::render::stage::RENDER, my_system.system())
.run();
}https://stackoverflow.com/questions/65457669
复制相似问题