MultiplayerSpawner not replicating scenes on clients.

Godot Version

4.4.1

Question

I am working on creating a peer-to-peer multiplayer game in Godot. I have successfully set up the multiplayer networking using the ENetMultiplayerPeer. I am successfully synchronizing lobby information using the MultiplayerSynchronizer and lobby chat messages with RPCs.

I am now at the point where I want to spawn the Player nodes via a MultiplayerSpawner. I run all the node-spawning code on the server (which has multiplayer authority) via the peer_connected and peer_disconnected signals. The nodes for each player successfully spawn on the server. However, the player nodes do not show on the client instances. The MultiplayerSpawner and Spawn Path node (called “Players”) are present on both instances as an autoload.

According to all the documentation I have read (and tutorials I have watched), this should work correctly. Any help is greatly appreciated!

Server Scene Tree after connection:

Client Scene Tree after connection:

I found the issue. I was trying to spawn my Player node using the .new() function. I didn’t realize that this is different than calling .instantiate() on a specific scene. So I added an @export to my MultiplayerManager autoload to contain the player_scene variable as a PackedScene.

The way I now understand it, .new() creates a new instance of the associated class/script (in my case player.gd). However, .instantiate() on a scene (in my case “player.tscn”) provides the correct association with the given “Auto Spawn List” scenes in the MultiplayerSpawner node.

I’ve attached a picture for more detail. Hopefully this helps someone else who makes the same mistake!

Correct way using MultiplayerManager.player_scene.instantiate(). The highlighted line used to read var new_player: Player = Player.new():