Fix para los items que no caen
This commit is contained in:
1 parent
1e70a99224
commit
5012879591
9 files changed
+144
-1468
No files matched your search
+12
-2
@@ -45,8 +45,18 @@ static func roll_drop(drop_table: PickupDropTable) -> Array[PickupData]:
|
||||
|
||||
|
||||
static func spawn_drops(drops_data: Array[PickupData], parent: Node, position: Vector2) -> void:
|
||||
# Death can happen inside a physics collision callback. Adding a new Area2D
|
||||
# immediately at that point is unsafe: defer its entry into the scene tree.
|
||||
# Set its local position first so it never briefly enters at the origin.
|
||||
var local_position: Vector2 = position
|
||||
if parent is Node2D:
|
||||
local_position = (parent as Node2D).to_local(position)
|
||||
|
||||
for data in drops_data:
|
||||
if data == null:
|
||||
push_warning("A drop was requested without PickupData.")
|
||||
continue
|
||||
var pickup := PICKUP_SCENE.instantiate() as Pickup
|
||||
pickup.pickup_data = data
|
||||
parent.add_child(pickup)
|
||||
pickup.global_position = position
|
||||
pickup.position = local_position
|
||||
parent.call_deferred("add_child", pickup)
|
||||
Reference in new issue
Block a user