Dropable loot in 2D RPG game

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By JustMyke


I’m having a surprisingly hard time trying to do what I see as a simple task. I need to spawn in a node (loot) around when another node (enemy or chest) is destroyed.

The only way I can think to do this is with add.child but that doesn’t seem to be working.

I’ve tried different variations of

onready var coins = get_node("/root/MainScene/Coins")

func on_interact(player):

to no avail. Any ideas?

:bust_in_silhouette: Reply From: exuin

When you use queue_free(), you delete the child nodes of the node you’re deleting. Since you made the coins node the child of the node that gets deleted, it gets deleted as well. So you shouldn’t make it a child node, just change its position to wherever you want it to be.

That makes perfect sense. Thanks

JustMyke | 2020-09-19 06:25