Fix para los items que no caen

This commit is contained in:
Diego De la Viuda Llorente committed 2026-10-21 11:22:00 +02:00
1 parent 1e70a99224
commit 5012879591
9 files changed
+144 -1468

No files matched your search

+13
View File
@@ -3,6 +3,10 @@ class_name Pickup
signal picked_up(pickup: Pickup, data: PickupData)
# Give players a moment to see the item before it can be collected. Otherwise
# a close-range kill may immediately pick it up inside the player's collision.
const PICKUP_GRACE_SECONDS: float = 0.75
@export var pickup_data: PickupData
@export var fall_speed: float = 150.0
@export var bob_amplitude: float = 4.0
@@ -27,6 +31,15 @@ func _ready() -> void:
placeholder.color = pickup_data.color
start_y = position.y
body_entered.connect(_on_body_entered)
_enable_collection_after_delay()
func _enable_collection_after_delay() -> void:
# The scene starts with monitoring disabled. Enabling it after the initial
# grace period also avoids overlap signals during creation in a physics tick.
await get_tree().create_timer(PICKUP_GRACE_SECONDS).timeout
if is_inside_tree():
monitoring = true
func _physics_process(delta: float) -> void: