fix: compare next vs current occupancy counts instead of absolute threshold
Two entities on the same tile (16,-0.0) each saw count=2 and blocked each other with occupied=true since 2>1. The collision check was treating the entity's own presence as a blocker. Now: only trigger avoidance when next_tile has strictly more entities than current_tile. Handles path[0]=current_pos (count equal → move), two entities passing through same tile (counts stay equal → move), and genuinely crowded destinations (next has more → dodge). Also raise crowded threshold to 4+.
This commit is contained in:
@@ -596,8 +596,10 @@ pub fn movement(
|
|||||||
if ambulatory.path_index < path.len() {
|
if ambulatory.path_index < path.len() {
|
||||||
let next_point = path[ambulatory.path_index];
|
let next_point = path[ambulatory.path_index];
|
||||||
|
|
||||||
let current_crowded = occupancy.count_at(transform.translation) > 2;
|
let current_count = occupancy.count_at(transform.translation);
|
||||||
let occupied = !current_crowded && occupancy.count_at(next_point) > 1;
|
let next_count = occupancy.count_at(next_point);
|
||||||
|
let current_crowded = current_count > 3;
|
||||||
|
let occupied = !current_crowded && next_count > current_count;
|
||||||
if occupied {
|
if occupied {
|
||||||
let move_dir = next_point - transform.translation;
|
let move_dir = next_point - transform.translation;
|
||||||
if move_dir.length_squared() > 0.0 {
|
if move_dir.length_squared() > 0.0 {
|
||||||
|
|||||||
Reference in New Issue
Block a user