Reduce creature flee speed

This commit is contained in:
Joshua Barretto 2023-05-14 22:18:01 +01:00
parent 0ec5ea87d7
commit 4732d28e24

View File

@ -574,6 +574,9 @@ impl<'a> AgentData<'a> {
read_data: &ReadData, read_data: &ReadData,
tgt_pos: &Pos, tgt_pos: &Pos,
) { ) {
// Proportion of full speed
const MAX_FLEE_SPEED: f32 = 0.65;
if read_data.is_riders.contains(*self.entity) { if read_data.is_riders.contains(*self.entity) {
controller.push_event(ControlEvent::Unmount); controller.push_event(ControlEvent::Unmount);
} }
@ -599,8 +602,8 @@ impl<'a> AgentData<'a> {
..self.traversal_config ..self.traversal_config
}, },
) { ) {
controller.inputs.move_dir = controller.inputs.move_dir = bearing.xy().try_normalized().unwrap_or_else(Vec2::zero)
bearing.xy().try_normalized().unwrap_or_else(Vec2::zero) * speed; * speed.min(MAX_FLEE_SPEED);
self.jump_if(bearing.z > 1.5, controller); self.jump_if(bearing.z > 1.5, controller);
controller.inputs.move_z = bearing.z; controller.inputs.move_z = bearing.z;
} }