19 lines
519 B
GDScript
19 lines
519 B
GDScript
extends Area2D
|
|
|
|
@export var duration: float = 5.0
|
|
@export var speed_multiplier: float = 1.8
|
|
|
|
@onready var animation_player: AnimationPlayer = $AnimationPlayer
|
|
|
|
func _on_body_entered(body: Node2D) -> void:
|
|
if body.is_in_group("player"):
|
|
animation_player.play("pickup")
|
|
_apply_boost(body)
|
|
|
|
func _apply_boost(player: Node) -> void:
|
|
var base_speed = player.speed
|
|
player.speed = base_speed * speed_multiplier
|
|
await get_tree().create_timer(duration).timeout
|
|
if is_instance_valid(player):
|
|
player.speed = base_speed
|