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
@ -34,7 +34,7 @@ struct BodyBundle {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn generate_bodies(
|
fn generate_bodies(
|
||||||
time: Res<Time>,
|
time: Res<Time<Fixed>>,
|
||||||
mut commands: Commands,
|
mut commands: Commands,
|
||||||
mut meshes: ResMut<Assets<Mesh>>,
|
mut meshes: ResMut<Assets<Mesh>>,
|
||||||
mut materials: ResMut<Assets<StandardMaterial>>,
|
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()),
|
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 New Issue
Block a user