acceleration

This commit is contained in:
Zynh Ludwig 2024-09-03 02:51:09 -07:00
parent 90600e1b1f
commit 92805832f2

View file

@ -60,6 +60,31 @@ fn cohesion(mut boids: Query<(Entity, &Transform, &mut SeperationAcceleration),
fn alignment(mut boids: Query<(Entity, &Transform, &mut SeperationAcceleration), With<Boid>>) {}
fn accelerate(
mut boids: Query<
(
&mut Velocity,
&mut SeperationAcceleration,
&mut CohesionAcceleration,
&mut AlignmentAcceleration,
),
With<Boid>,
>,
time: Res<Time>,
) {
boids
.par_iter_mut()
.for_each(|(mut vel, mut sep, mut coh, mut ali)| {
vel.0 += sep.0 * time.delta_seconds();
vel.0 += coh.0 * time.delta_seconds();
vel.0 += ali.0 * time.delta_seconds();
sep.0 *= 0.;
sep.0 *= 0.;
sep.0 *= 0.;
});
}
fn move_boids(mut boids: Query<(&mut Transform, &Velocity), With<Boid>>, time: Res<Time>) {
boids.par_iter_mut().for_each(|(mut transform, velocity)| {
transform.translation += velocity.0.extend(0.) * time.delta_seconds();