Quick question about queue_free and add_child

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

how can i make when a enemy is killed (queue_free) a item (a scene) will appear where he died?

:bust_in_silhouette: Reply From: Asthmar

call add_child(Scene) before you call queue_free.

And to make it appear where the enemy died you must also set the position before freeing

Scene.global_position = enemy.global_position

Example

func died():
var loot = Scene.instance
loot.global_position = global position
Add_child(“loot”)