godot icon indicating copy to clipboard operation
godot copied to clipboard

MultiplayerSpawner doesn't work with UIDs

Open Summersay415 opened this issue 10 months ago • 5 comments

Tested versions

Reproducible in: 4.3dev5, 4.2.2, latest master [4a0160241fd0c1e874e297f6b08676cf0761e5e8]

System information

Godot v4.2.2.stable - Ubuntu 23.10 23.10 - X11 - GLES3 (Compatibility) - Mesa Intel(R) Graphics (ADL GT2) () - 12th Gen Intel(R) Core(TM) i5-1235U (12 Threads)

Issue description

MultiplayerSpawner doesn't work if auto spawn path is UID. It prints some errors in console:

E 0:00:08:0516   get_node: Node not found: "World/Players/1/MultiplayerSynchronizer" (relative to "/root").
  <Ошибка C++>   Method/function failed. Returning: nullptr
  <Исходный код C++>scene/main/node.cpp:1651 @ get_node()
E 0:00:08:0516   process_simplify_path: Parameter "node" is null.
  <Исходный код C++>modules/multiplayer/scene_cache_interface.cpp:110 @ process_simplify_path()
E 0:00:08:0516   get_node: Node not found: "World/Players/1/Inputs/InputsSync" (relative to "/root").
  <Ошибка C++>   Method/function failed. Returning: nullptr
  <Исходный код C++>scene/main/node.cpp:1651 @ get_node()
E 0:00:08:0516   process_simplify_path: Parameter "node" is null.
  <Исходный код C++>modules/multiplayer/scene_cache_interface.cpp:110 @ process_simplify_path()
E 0:00:08:0516   get_node: Node not found: "World/Players/168206040/MultiplayerSynchronizer" (relative to "/root").
  <Ошибка C++>   Method/function failed. Returning: nullptr
  <Исходный код C++>scene/main/node.cpp:1651 @ get_node()
E 0:00:08:0516   process_simplify_path: Parameter "node" is null.
  <Исходный код C++>modules/multiplayer/scene_cache_interface.cpp:110 @ process_simplify_path()

Also, after each engine restart UID is erased from Auto Spawn List with error in console:

modules/multiplayer/multiplayer_spawner.cpp:103 - Condition "!FileAccess::exists(p_path)" is true.

Can be worked around with ResourceUID.get_id_path(ResourceUID.text_to_id()), but only if spawnable scenes added in code.

Steps to reproduce

  1. Take multiplayer project with MultiplayerSpawner which uses Auto Spawn List (Multiplayer Bomber in MRP)
  2. Change paths of Auto Spawn List scenes to UIDs
  3. Run game as usual
  4. Request spawn Notice no scenes spawned on client, instead errors printed.

Minimal reproduction project (MRP)

bomber.zip

  1. Open world.tscn
  2. in PlayerSpawner add UID of player.tscn
  3. Run the game, create server and connect from client
  4. Start game
  5. Observe result

Summersay415 avatar Apr 19 '24 14:04 Summersay415

File access can't open UIDs like this, that's limited to the resource management system, so this is a limitation in that side of things, unsure how to proceed though

Note that UIDs are not guaranteed to be valid in the other client, as you might be communicating with a different version of the game, including having a separate server build

AThousandShips avatar Apr 19 '24 15:04 AThousandShips

This should be documented then?

Summersay415 avatar Apr 19 '24 15:04 Summersay415

Depending on what path we take yes, the team for multiplayer should evaluate if this is a feature we should add, or document that it's not supported

AThousandShips avatar Apr 19 '24 15:04 AThousandShips

It seems to be an error in this case, the loading itself uses ResourceLoader so the check should be replaced by ResourceLoader::exists instead, as it works otherwise

AThousandShips avatar Apr 19 '24 15:04 AThousandShips

First time contributor, here's my pull request #91084

OwenAEdwards avatar Apr 23 '24 23:04 OwenAEdwards

I think it will make sense if Auto Spawn List will be changed to Array of Strings with PROPERTY_HINT_RESOURCE_UID (introduced in #91815): It will work with UIDs and automatically updated when scene has been moved

Summersay415 avatar May 25 '24 12:05 Summersay415

UIDs are not always available or desirable, forcing people to use them for networking isn't a good idea IMO

Also that's for the future assuming that PR is merged, irrelevant to this (which has to do with UIDs not being processed correctly for spawners)

AThousandShips avatar May 25 '24 14:05 AThousandShips