instancing thing from within instanced thing

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

Basically, what do I do when I need to do instance a scene within an instance?

Say, for example, an enemy shoots a bullet. The enemy is an instance, and the bullet is instanced by the enemy. Do I load the bullet over and over for each enemy? or store whatever in a variable in another node? Any help is appreciated!

:bust_in_silhouette: Reply From: Merlin1846

Just load the bullet once in a script at the scene root, then when an enemy shoots simply grab an instance of that loaded copy at the scene root. That’s probably the simplest way to do what you want.

But does load() or preload() load the stuff all over again, or does it keep some form of “cache” or point to the scene after it’s been loaded? Also, how can I access this variable without some get_parent().get_parent() spaghetti code?

Mezlux | 2021-12-30 08:46