Skip to content

SimpleSpawner: Allow spawning nodes as child of scene #251

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 9, 2024

Conversation

wjt
Copy link
Member

@wjt wjt commented Oct 9, 2024

In the current implementation, spawned nodes are children of the spawner. In some cases this behaviour is what you want, but it means it's not possible to change the spawn position of future scenes without moving already-spawned scenes.

Add a new property to SimpleSpawner which allows choosing a new mode where spawned scenes are made children of the root scene.

The change in spawn_start() is necessary because, if the Start Spawning block is used in the On Ready entrypoint, this results in spawn_start() being called from the SimpleSpawner's _ready() function. At this point, the SimpleSpawner itself is ready but the root scene is not. In this case, attempting to add a child to the root scene logs an error, and a later attempt to get the spawned scene's parent to remove it returns undefined.

In the current implementation, spawned nodes are children of the spawner. In
some cases this behaviour is what you want, but it means it's not possible to
change the spawn position of future scenes without moving already-spawned
scenes.

Add a new property to SimpleSpawner which allows choosing a new mode where
spawned scenes are made children of the root scene.

The change in spawn_start() is necessary because, if the Start Spawning block
is used in the On Ready entrypoint, this results in spawn_start() being called
from the SimpleSpawner's _ready() function. At this point, the SimpleSpawner
itself is ready but the root scene is not. In this case, attempting to add a
child to the root scene logs an error, and a later attempt to get the spawned
scene's parent to remove it returns undefined.
@wjt wjt requested review from manuq and dbnicholson October 9, 2024 15:51
@dbnicholson dbnicholson merged commit f1ea1c5 into main Oct 9, 2024
3 checks passed
@dbnicholson dbnicholson deleted the simple-spawner-spawn-parent branch October 9, 2024 16:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants