From fc3f7590c7c3ff623cdcf3c8c6978ea2876f452a Mon Sep 17 00:00:00 2001 From: Isse Date: Wed, 12 Apr 2023 16:59:49 +0200 Subject: [PATCH] clamp chase_tgt to ground if we can't fly --- server/agent/src/action_nodes.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/server/agent/src/action_nodes.rs b/server/agent/src/action_nodes.rs index 00d91db232..a5e8c66e7b 100644 --- a/server/agent/src/action_nodes.rs +++ b/server/agent/src/action_nodes.rs @@ -233,11 +233,13 @@ impl<'a> AgentData<'a> { controller.push_cancel_input(InputKind::Fly) } - let chase_tgt = read_data - .terrain - .try_find_space(travel_to.as_()) - .map(|pos| pos.as_()) - .unwrap_or(travel_to); + let chase_tgt = if self.traversal_config.can_fly { + read_data.terrain.try_find_space(travel_to.as_()) + } else { + read_data.terrain.try_find_ground(travel_to.as_()) + } + .map(|pos| pos.as_()) + .unwrap_or(travel_to); if let Some((bearing, speed)) = agent.chaser.chase( &*read_data.terrain,