Fix cohesion force vector

Found it! The force was going the wrong way.
This commit is contained in:
2024-07-09 16:42:19 -05:00
parent 4cf591f937
commit 5d41cd57d3

View File

@@ -172,7 +172,7 @@ fn cohesion(
.sum::<Vec2>() / neighbors.len() as f32;
for (transform, mut velocity) in &mut query {
let towards = (transform.translation.xy() - center_of_mass).normalize();
let towards = (center_of_mass - transform.translation.xy()).normalize();
**velocity += towards.extend(0.0) * COHESION_FACTOR;
}
}