Just use a for loop in the cohesion function
I was trying to work out a way to run the loop using iterators, but that doesn't really matter. I had an empty loop to consume the results, which means I just have a for loop anyway.
This commit is contained in:
@@ -159,8 +159,7 @@ fn cohesion(
|
|||||||
boids: Query<&Transform, With<Boid>>,
|
boids: Query<&Transform, With<Boid>>,
|
||||||
mut velocities: Query<&mut Velocity, With<Boid>>,
|
mut velocities: Query<&mut Velocity, With<Boid>>,
|
||||||
) {
|
) {
|
||||||
let it = boids.iter()
|
for transform in &boids {
|
||||||
.map(|transform| {
|
|
||||||
let neighbors = spatial_tree.within_distance(
|
let neighbors = spatial_tree.within_distance(
|
||||||
transform.translation.xy(),
|
transform.translation.xy(),
|
||||||
BOID_VIEW_RANGE
|
BOID_VIEW_RANGE
|
||||||
@@ -175,8 +174,5 @@ fn cohesion(
|
|||||||
**velocity += towards.extend(0.0) * COHESION_FACTOR;
|
**velocity += towards.extend(0.0) * COHESION_FACTOR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
|
||||||
for _ in it{
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user