game: add magnet pickup

This commit is contained in:
2025-08-20 04:35:40 +02:00
parent 515e2a53e0
commit 702080af59
13 changed files with 119 additions and 5 deletions

View File

@@ -17,9 +17,11 @@ func _physics_process(delta: float) -> void:
var to_player = player.global_position - global_position
var dist = to_player.length()
var attract_radius = player.player_stats.get_final("pickup_radius", player.modifiers)
var adjusted_max_speed = clampf((attract_radius / 50.0) * max_speed, min_speed, max_speed * 5)
var adjusted_min_speed = clampf((attract_radius / 50.0) * min_speed, min_speed, min_speed * 5)
if dist < 4:
return
if dist < attract_radius:
var dir = to_player.normalized()
var speed = lerp(min_speed, max_speed, (attract_radius - dist) / attract_radius)
var speed = lerp(adjusted_min_speed, adjusted_max_speed, (attract_radius - dist) / attract_radius)
global_position += dir * speed * delta