summaryrefslogtreecommitdiffstats
path: root/player.gd
diff options
context:
space:
mode:
authorJan Tuomi <jan@jantuomi.fi>2025-11-28 16:12:51 +0200
committerJan Tuomi <jan@jantuomi.fi>2025-11-28 16:12:51 +0200
commit2d46aa29b8514a6bce39baeae6e85e89fb5e20f7 (patch)
tree28eebc633a7ecd938eda2a73c96d50650e311e74 /player.gd
parentb140b2107c23b9eb67afe29d3186f99ad67c0201 (diff)
Snap to horiz if above hook
Diffstat (limited to 'player.gd')
-rw-r--r--player.gd10
1 files changed, 8 insertions, 2 deletions
diff --git a/player.gd b/player.gd
index 9b4eebc..738b5dd 100644
--- a/player.gd
+++ b/player.gd
@@ -124,8 +124,14 @@ func set_movement_hanging(target: Node2D, hang_dist: float):
hanging_t = 0
hanging_L = hang_dist
hanging_target = target
- var theta0_sign = sign(global_position.x - target.global_position.x)
- hanging_theta0 = deg_to_rad(theta0_sign * 30)
+
+ var hyp = target.global_position - global_position
+ # if player is above the hook, we need to snap to horizontal
+ if hyp.y > 0: hyp.y = 0
+
+ hanging_theta0 = atan2(-hyp.y, hyp.x) - PI/2
+ if hanging_theta0 < -PI: hanging_theta0 += 2*PI
+ print_debug("hyp: ", hyp, ", hanging_theta0: ", hanging_theta0)
hanging_line2D = Line2D.new()
hanging_line2D.width = 2