From 98c33cfa06732b630522c836d9686243ced891ad Mon Sep 17 00:00:00 2001 From: metamuffin Date: Fri, 16 Aug 2024 21:57:13 +0200 Subject: interp item to next 90° rotation when on tile MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/global.gd | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'client/global.gd') diff --git a/client/global.gd b/client/global.gd index 647cac32..d660173a 100644 --- a/client/global.gd +++ b/client/global.gd @@ -350,10 +350,17 @@ static func interpolate_angle(current, target, dt): current = fmod(current, PI * 2) target = fmod(target, PI * 2) if abs(target - current) > PI: - if target < 0: - target += PI * 2 - else: - target -= PI * 2 + if target < 0: target += PI * 2 + else: target -= PI * 2 + return target + (current - target) * exp(-dt) + +# TODO not working in all cases yet but there was an attempt +static func interpolate_angle_closest_quarter(current, target, dt): + current = fmod(current, PI * 2) + target = fmod(target, PI * 2) + while abs(target - current) > PI / 4.: + if target - current < 0: target += PI / 2 + else: target -= PI / 2 return target + (current - target) * exp(-dt) func find_menu(node: Node) -> Menu: -- cgit v1.2.3-70-g09d2