parallel update

This commit is contained in:
Zynh Ludwig 2024-09-03 01:25:23 -07:00
parent f7c548074d
commit 7d5335fb2e

View file

@ -61,11 +61,11 @@ fn cohesion(mut boids: Query<(Entity, &Transform, &mut SeperationAcceleration),
fn alignment(mut boids: Query<(Entity, &Transform, &mut SeperationAcceleration), With<Boid>>) {}
fn move_boids(mut boids: Query<(&mut Transform, &Velocity), With<Boid>>, time: Res<Time>) {
for (mut transform, velocity) in &mut boids {
boids.par_iter_mut().for_each(|(mut transform, velocity)| {
transform.translation += velocity.0.extend(0.) * time.delta_seconds();
transform.rotation =
Quat::from_rotation_z(velocity.0.to_angle() - std::f32::consts::FRAC_PI_2);
}
});
}
fn setup(