在 Amethyst 或许多其他游戏引擎中,逻辑的 update
和渲染的 fixed_update
之间存在区别。
Bevy 0.4 引入了状态,但只有 enter
、update
和 exit
生命周期 Hook 。
可以使用 stage
模块中的常量创建自定义阶段,但它仅添加 POST_UPDATE
和 PRE_UPDATE
。
我的问题在标题中,但此外,如果没有等效的内容,是否有运行处理渲染的系统的最佳实践?
一个可行的解决方案是制作第二个更新系统(例如称为渲染),但我的目标是如果有更好的方法来提高性能。
最佳答案
我不知道这对于您的用例是否有帮助,但在 bevy 0.4 announcement 中这个示例显示可以使用 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
标准在内部是如何工作的),但在大多数情况下应该足够了。
编辑
我发现可以使用 render App stages作为舞台名称,应该更符合您的需求:
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();
}
关于rust - Amethyst 的fixed_update 是否有Bevy 等效项?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65457669/