mirror of
https://github.com/bevyengine/bevy
synced 2024-11-10 07:04:33 +00:00
examples/ecs/iter_combinations: Initialize velocity using fixed timestep (#10673)
# Objective On some platforms (observed on Windows and Linux, works fine on web), velocity of all entities would be initialized to zero, making them simply fall into the star. ## Solution Using `Time<Fixed>::timestep` instead of `Time::delta_seconds` to initialize velocity. Since the entities are generated in the startup schedule, no time has elapsed yet and `Time::delta_seconds` would return zero on some platforms. `Time<Fixed>::timestep` will always return the expected time step of `FixedUpdate` schedule.
This commit is contained in:
parent
fd0f1a37ad
commit
8020805830
1 changed files with 2 additions and 2 deletions
|
@ -34,7 +34,7 @@ struct BodyBundle {
|
|||
}
|
||||
|
||||
fn generate_bodies(
|
||||
time: Res<Time>,
|
||||
time: Res<Time<Fixed>>,
|
||||
mut commands: Commands,
|
||||
mut meshes: ResMut<Assets<Mesh>>,
|
||||
mut materials: ResMut<Assets<StandardMaterial>>,
|
||||
|
@ -81,7 +81,7 @@ fn generate_bodies(
|
|||
rng.gen_range(vel_range.clone()),
|
||||
rng.gen_range(vel_range.clone()),
|
||||
rng.gen_range(vel_range.clone()),
|
||||
) * time.delta_seconds(),
|
||||
) * time.timestep().as_secs_f32(),
|
||||
),
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue