Skip to content

Commit 13151f0

Browse files
committed
delete pickup object when finished animation (send it to the shadow realm)
1 parent 4a78607 commit 13151f0

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

Scenes and Scripts/Scenes/Player/Player_SCRIPT.gd

+16-6
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ var is_crouching = false
161161

162162
@onready var head = $Head # Reference to the head of the player scene. (used for mouse movement and looking around)
163163
@onready var camera = $Head/Camera3D # Reference to the camera of the player (used for mouse movement and looking around)
164+
var pickup_slot_ref
164165

165166
######################################
166167
# Input
@@ -642,19 +643,28 @@ func _on_pickup_object_detector_area_entered(area: Area3D) -> void:
642643

643644
if free_slot != null:
644645
# Use the free_slot variable as needed
645-
print("Free slot found: " + free_slot.name)
646+
print("{LOCAL} [Player_SCRIPT.gd] Free slot found: " + free_slot.name)
647+
648+
646649

647650
var PickupObject = area.get_parent()
648651
var PickupItemType = PickupObject.get_ITEM_TYPE()
649652
var PlayerPos = $PickupAttractionPos.global_position
653+
650654
print("{LOCAL} [Player_SCRIPT.gd] Collided with pickup player detector! Item: " + PickupItemType)
651655

652656
var tween = get_tree().create_tween()
657+
653658
tween.tween_property(PickupObject, "position", PlayerPos, 0.3).set_ease(Tween.EASE_IN_OUT).set_trans(Tween.TRANS_SINE)
654-
tween.connect("finished", Callable(self, "on_pickup_anim_finished"))
655-
659+
tween.tween_property(PickupObject, "position", Vector3(10000, 10000, 10000), 0) # send it to the shadow realm
660+
tween.tween_interval(2)
661+
662+
await get_tree().create_timer(2.3).timeout
663+
delete_pickup_object(PickupObject)
656664
else:
657-
print("No free slot available")
665+
print("{LOCAL} [Player_SCRIPT.gd] No free slot available")
658666

659-
func on_pickup_anim_finished():
660-
pass
667+
668+
669+
func delete_pickup_object(pickupobj):
670+
pickupobj.queue_free()

project.godot

-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ SmoothMovements="*res://Scenes and Scripts/Singletons/SmoothMovements.gd"
4242

4343
[display]
4444

45-
window/size/mode=4
4645
window/stretch/mode="canvas_items"
4746

4847
[editor]

0 commit comments

Comments
 (0)