Should it send a signal to the game or map upon death, and then let the game or map run code to instance the new node?
That’s one way.
Another way is using Node.owner which is the root node in the saved scene (the Game).
func drop():
var loot = LootScene.instance()
owner.add_child(loot)
If the trees, goblins or apples are spawned at runtime, you may need to manually set the owner to the Game node.
Say a tree drops an apple:
func spawn_apple():
var apple = AppleScene.instance()
owner.add_child(apple)
apple.owner = owner # the tree's owner is probably the game
Thank you very much, I’ll try this.
mattkw80 | 2020-08-08 16:01
Thanks Jeans…
I went with the owner.add_child way of doing it.
The signal way might be more proper… but I’m already connecting enough signals with my map does my procgen… I’m getting sick of tracking them all.
Your owner.add_child method is easy enough…
mattkw80 | 2020-08-08 19:44
Hmm had to abandon this, heading back into using Signals.
I realized when I have the ‘apple’ make the new instance of ‘rotten_apple’ and try to push it into ‘Game’… I have no way of hooking ‘rotten_apple’'s signals up to ‘Game’. At least not in anyway that I can make work.