Skip to content

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 dbnicholson and manuq 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.

3 participants