From cea8b52bc34e5df49e2ded3de742b928ad0671c3 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Wed, 25 Sep 2024 16:07:46 +0200 Subject: bot: stronger rotation alignment --- server/bot/src/algos/customer.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'server/bot/src/algos/customer.rs') diff --git a/server/bot/src/algos/customer.rs b/server/bot/src/algos/customer.rs index 0c38c79d..64ae726f 100644 --- a/server/bot/src/algos/customer.rs +++ b/server/bot/src/algos/customer.rs @@ -285,7 +285,7 @@ impl BotAlgo for Customer { } } BotInput { - direction: (chair.as_vec2() + 0.5) - pos + *facing * 0.3, + direction: dir_input(pos, *chair, *facing), ..Default::default() } } @@ -322,7 +322,7 @@ impl BotAlgo for Customer { }; } BotInput { - direction: (chair.as_vec2() + 0.5) - pos + (*table - *chair).as_vec2() * 0.3, + direction: dir_input(pos, *chair, (*table - *chair).as_vec2()), ..Default::default() } } @@ -380,3 +380,12 @@ impl BotAlgo for Customer { } } } + +fn dir_input(pos: Vec2, target: IVec2, facing: Vec2) -> Vec2 { + let diff = (target.as_vec2() + 0.5) - pos; + (if diff.length() > 0.3 { + diff.normalize() + } else { + diff * 0.5 + }) + facing.clamp_length_max(1.) * 0.3 +} -- cgit v1.2.3-70-g09d2