clamp chase_tgt to ground if we can't fly

This commit is contained in:
Isse 2023-04-12 16:59:49 +02:00
parent cb5d0f5a95
commit fc3f7590c7

View File

@ -233,11 +233,13 @@ impl<'a> AgentData<'a> {
controller.push_cancel_input(InputKind::Fly) controller.push_cancel_input(InputKind::Fly)
} }
let chase_tgt = read_data let chase_tgt = if self.traversal_config.can_fly {
.terrain read_data.terrain.try_find_space(travel_to.as_())
.try_find_space(travel_to.as_()) } else {
.map(|pos| pos.as_()) read_data.terrain.try_find_ground(travel_to.as_())
.unwrap_or(travel_to); }
.map(|pos| pos.as_())
.unwrap_or(travel_to);
if let Some((bearing, speed)) = agent.chaser.chase( if let Some((bearing, speed)) = agent.chaser.chase(
&*read_data.terrain, &*read_data.terrain,