use bevy::prelude::*;
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_systems(Update, frame_update)
.add_systems(FixedUpdate, fixed_update)
.insert_resource(Time::<Fixed>::from_seconds(0.5))
.run();
}
fn frame_update(mut last_time: Local<f32>, time: Res<Time>) {
info!(
"time since last frame_update: {}",
time.elapsed_seconds() - *last_time
);
*last_time = time.elapsed_seconds();
}
fn fixed_update(mut last_time: Local<f32>, time: Res<Time>, fixed_time: Res<Time<Fixed>>) {
info!(
"time since last fixed_update: {}\n",
time.elapsed_seconds() - *last_time
);
info!("fixed timestep: {}\n", time.delta_seconds());
info!(
"time accrued toward next fixed_update: {}\n",
fixed_time.overstep().as_secs_f32()
);
*last_time = time.elapsed_seconds();
}