game: add magnet pickup
This commit is contained in:
@@ -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
|
||||
|
Reference in New Issue
Block a user