Which Multiplayer node should I use to Synchronise Itemlist?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By pleyland

I just updated my entire game to Godot 4.0 right before implementing multiplayer. With Godot 3.0 I was able to get a demo of websocket multiplayer, but that demo is broken in the new version, and I am following a tutorial on the new methods.

I am now stuck trying to get the old demo to work with the new methods, and the reason is because the itemList does not add nodes in the normal way.

I understand that to spawn new nodes for all clients you use a spawner, and to synchronize properties you use a synchronizer, but itemlists contain neither spawned nodes nor are there lists properties of the node. When you add items to the list they are added as new properties, so I’m unable to select the items as properties by the synchronizer before they are added.

The obvious solution is to add the properties to the synchronizer at runtime with a script, but that is apparently not an option.

It’s very weird to have the entire system change as soon as you learn the old one. Would it be better to simply roll back to a previous version? It does not seem like anyone on planet earth has figured out how to use these new things yet. It was hard enough updating my entire game to godot 4.0, I felt like a pioneer.

As an update I have made a small amount of progress by adding a empty node with a spawner in it linked to a scene resource of simple empty nodes. The spawner keeps track of them, and I added a script on the itemList that counts the children of the empty node each frame and updates the list.

This currently works in 1 direction, as in the server can send the info to the client, but unfortunately the client is unable to send info to the server because it’s not the authority, so when it adds items to the list the spawner does not recognise them.

It’s a lost cause anyways, as checking a list of empty nodes every frame just to update 1 list is obviously not the correct method. It would help if there was a signal for adding stuff to a list.

This new networking method is supposed to be an improvement, but the old @rpc calls seemed much easier. It seems like there is no way to call a function on all peers with the new system.

I just want to know if it’s still possible to use @rpc, or if it’s now defunct.

Apologies for this but it’s difficult to find info on these new systems elsewhere

pleyland | 2023-03-16 08:58

Okay I realise now that this is noobish behaviour. I realised that I can just use the built in MultiplayerPeer Functions like peer_connected to change the itemlist and then just update it with the synch. Makes much more sense like that.

The confusing here comes from the fact that they moved the peer_connected function from the sceneTree to the multiplayer peer, so this kind of code should work to reconnect broken connections, add it at the end of your server or client connections:

peer.peer_connected.connect(Callable(self,“_peer_connected”))

Where:
var peer = ENetMultiplayerPeer.new()
peer.create_server(PORT)

and
func _peer_connected(id)

pleyland | 2023-03-16 10:15

This was a very noob question, and I will encourage anyone else to look up RPC calls. Godot 4.0 still uses RPC and it’s very useful and easy.

pleyland | 2023-03-18 17:28