Compare commits

...

2 Commits

Author SHA1 Message Date
Zynh Ludwig 0803b9d611 proper for loop 2024-09-01 15:14:47 -07:00
Zynh Ludwig edc9b376b9 faster and time agnostic movement 2024-09-01 15:13:35 -07:00
1 changed files with 5 additions and 5 deletions

View File

@ -25,10 +25,10 @@ struct BoidBundle {
boid: Boid, boid: Boid,
} }
fn move_boids(mut boids: Query<(&mut Transform, &Velocity), With<Boid>>) { fn move_boids(mut boids: Query<(&mut Transform, &Velocity), With<Boid>>, time: Res<Time>) {
boids.iter_mut().for_each(|(mut transform, velocity)| { for (mut transform, velocity) in &mut boids {
transform.translation += velocity.0; transform.translation += velocity.0 * time.delta_seconds();
}); }
} }
fn setup( fn setup(
@ -47,7 +47,7 @@ fn setup(
transform: Transform::from_scale(Vec3::splat(2.5)), transform: Transform::from_scale(Vec3::splat(2.5)),
..default() ..default()
}, },
velocity: Velocity(Vec3::Y), velocity: Velocity(Vec3::Y * 25.),
..default() ..default()
}); });
} }