godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
91.07k stars 21.18k forks source link

MultiplayerReplicator does not properly sync scene inside other scene #55734

Closed nathanfranke closed 2 years ago

nathanfranke commented 2 years ago

Godot version

v4.0.dev.custom_build [04fac59f3]

System information

Linux x86_64 on 5.15.6-zen2-1-zen

Issue description

I am working on an RTS game which syncs the Map scenes. However, the Map scenes may also have Player nodes as children (e.g. bots or premade players). When the server instantiates a Map scene, the Player children are also automatically spawned, which triggers another spawn call on the client, leading to this problem.

The subscenes also don't sync their properties, as can be seen in the MRP

Scene Layout, SyncMain as root and SyncSub as a child

Server:

Synced string: Hello World!
Synced string: Hello World!
Synced string: Hello World!
Synced string: Hello World!
Synced string: Hello World!

Client:

ERROR: Unable to spawn node. Node already exists: /root/Scene/SyncMain/SyncSub
   at: _process_default_spawn_despawn (core/multiplayer/multiplayer_replicator.cpp:267)
Synced string: Default
Synced string: Default
Synced string: Default
Synced string: Default
Synced string: Default

Steps to reproduce

1) Run MRP with --server 2) Run MRP at the same time without any arguments

Minimal reproduction project

Test14.zip

Faless commented 2 years ago

Thanks, this is currently expected but will be fixed with the new MultiplayerSpanwer node.

Faless commented 2 years ago

Closing, as this should now be possible with the new API (which can be configured to not spawn nodes automatically).