MultiplayerSpawner for indirect children

Godot Version

4.2 and 4.3 RC1

Question

tl;dr: Is there a way to have multiplayerspawner spawn nodes further down the scene tree?

Longer version: I’m making a spaceship game (X series, Elite, Freelancer, etc) with dedicated server multiplayer, so I need the client to be able to hotjoin a game. Multiple, independent star systems are running in different subviewports in order to have separate physics worlds. Players, and npc, can transfer to other craft, or even multiple players on one craft.

My hope is to have both spacecraft and pilots use the magic of the multiplayerspawner. My initial design plan was to parent the “Pilot” nodes to whatever ship that character is currently on. However MultiplayerSpawner will only network the node if it is a direct child of the node MultiplayerSpawner is watching, so the pilot nodes do not propagate to the clients.

My current workaround is that each star system will have a Pilots and Ships node that the Ship and Pilot Spawners will watch. Each pilot and ship will have a variable that references the ship they are on, or who is on that ship. Then I’ll have to reparent, or destroy and recreate, the ships and pilots if they jump to another star system.

I am wondering if there is a way to get a spawner to watch a bigger section of the scene graph, or if there is a more elegant way for me to design this. Thanks for any feedback!

It is possible, but I wonder if the spawner needs to handle all the nodes in the branch.

I.e. You shouldn’t use multiple spawner nodes. That would be hard to coordinate in code, taking turns to spawn node children, I wouldn’t want to program that…

So, because of this of you could have all the nodes in a branch be handled by one spawner, I think it should work.

I turned off the other spawners (each handles one note type). Nodes wont spawn on the client if they are nested at all.

Hugh, maybe it’s not possible…? I remember it was a video talking about with a tank demo.

Chapter two talks about nested scenes.

Anyway I tried to test this myself but was unsuccessful.

1 Like

Oh! I haven’t tested, but it looks like as long as one of the Auto Spawn Scenes is a direct child of the spawn path, additional spawned scenes can be nested in those. However if there are nodes that are not on the approved scene list, the spawner wont look into those. I’ll need to test in when I have a chance

I have an architecture of a spawner that watches player; player has a spawner that watches weapons.

“cascading spawners”, and it has worked so far for me.