This commit is contained in:
2026-03-22 16:45:46 +00:00
parent 738f595f67
commit ffb0e79cf3
+16 -1
View File
@@ -146,10 +146,25 @@ pub fn task_executor_system(
continue; continue;
} }
if ambulatory.target.is_none() { if ambulatory.target.is_none() {
// Find the actual ground level at the trunk's XY for pathfinding.
// Walking to the trunk itself (z + 1.0) may land on an unreachable tile.
// Instead, find a standable tile at the trunk's XY location.
let ground_z = (0..=4i32)
.map(|z| {
IVec3::new(
trunk_pos.x,
trunk_pos.y,
z * crate::constants::ITILE_SIZE,
)
})
.find(|&pos| tilemap_mut.is_standable(pos))
.map(|pos| pos.z as f32 + 1.0)
.unwrap_or(trunk_pos.z as f32 + 1.0);
ambulatory.target = Some(Vec3::new( ambulatory.target = Some(Vec3::new(
trunk_pos.x as f32, trunk_pos.x as f32,
trunk_pos.y as f32, trunk_pos.y as f32,
trunk_pos.z as f32 + 1.0, ground_z,
)); ));
ambulatory.current_path = None; ambulatory.current_path = None;
} }