acceleration
This commit is contained in:
parent
90600e1b1f
commit
92805832f2
1 changed files with 25 additions and 0 deletions
25
src/main.rs
25
src/main.rs
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue