#Multiplayer Synchronizer not Syncing

1 messages · Page 1 of 1 (latest)

fresh shale
#

Hello. I am trying to build a simple prototype based off https://www.youtube.com/watch?v=ulfGNtiItnc (using WebRTC for multiplayer).

So far I followed the tutorial, which I thought was very good, and I got it working with the demo scene. But I wanted to create my own 3D multiplayer scene. Almost got it working I think, but now I'm stuck because I can spawn players and control just my player on the screen, but there's no synchronization going on.

I have a multiplayer synchronizer node in my Player scene that's supposed to be syncing the player position and rotation. And I think I've found a way to set the multiplayer authority. But otherwise I'm stuck.

I'm not seeing anything in the RPC Network logs for either player. They're just empty.
I've tried both of these in the player scene, neither solves my problem but I don't know if they conflict, etc.

func _enter_tree():
    set_multiplayer_authority(name.to_int())
    print(name, is_multiplayer_authority())
func _ready():
    $MultiplayerSynchronizer.set_multiplayer_authority(str(name).to_int())

Also, this is how I'm spawning players when the test scene loads, based on a GameManager.Players list (that works properly):

func _ready():
    var index = 1
    
    for i in GameManager.Players:
        var currentPlayer: Node = load("res://scenes/Player.tscn").instantiate()
        currentPlayer.name = str(GameManager.Players[i].id)
        add_child(currentPlayer)
        for spawn in get_tree().get_nodes_in_group("PlayerSpawnPoint"):
            if spawn.name == str(GameManager.Players[i].index):
                currentPlayer.global_position = spawn.global_position
        index += 1

And there is a MultiplayerSpawner node in the test scene as well, but I don't know if it does anything.

Any help would be appreciated. I can also provide code samples or the whole project if necessary.

Subscribe and learn more from me about Game Development and Programming!

In this video, we discuss how to use WebRTC with Godot!

Links:
Starter Project: https://github.com/finepointcgi/WebRTC-with-Godot-Tutorial
Finished Project: https://github.com/finepointcgi/WebRTC-with-Godot-Tutorial/tree/Finished-Product

WebRTC plugin: https://github.co...

▶ Play video
#

Network Profiler is empty for all sessions:

#

Here's my test scene:

pallid jacinth
# fresh shale Here's my test scene:

Your spawner’s not doing anything but that should be ok for now because you’re setting the nodes up properly on both client and server. What’s the Remote view of your two game instances look like?

fresh shale
#

Thanks. I figured the spawner was just a placebo atm, but just wanted to make sure it wasn't interfering.

The Remote view for both players looks identical (at least from the node view):

pallid jacinth
#

The host should have id 1

#

How are you doing these ids?

fresh shale
#

Interesting. OK.
Well, I'm using WebRTC as per the tutorial, and these IDs are the peer IDs as assigned by the server. Sorry for not mentioning, there's a third game instance running in server mode, and two players atm.

But both players know who they are, and that that weird ID is them and not the other guy.

pallid jacinth
#

Ahhh ok that confused me for a sec

#

The server is setting up the synchronizer too right?

#

Iirc the traffic still gets routed through the server? Could be misremembering

fresh shale
#

Hmm... Well this is the server's remote view. No test scene, players, or synchronizers to be found.
So clearly I'm missing something, because I guess what's supposed to happen is either the scene should look like this for the server, or the clients should be communicating to each other directly.

My goal with setting up WebRTC was to have the clients talk to each other, like P2P but with extra steps so it actually works across firewalls, behind NAT, etc. Where the server acts as a relay of sorts, but not really in the sense that all traffic has to go through it first. More in the sense that it's the central location for the players to find out about and connect to each other.

I'll be honest, I don't fully understand the ins and outs of it the way I'm implementing it here, or if it's ideal. Sorry if that complicates things. But I feel like I'm really close, because the player can find and connect to each other now. The syncronization just doesn't want to work.

pallid jacinth
#

I think short of modifying the WebRTCPeer class yourself you’ll have to get the players along with the synchronizer on the server

#

You can disable all the things the server doesn’t need like making everything invisible so there’s no rendering and such

#

But you’ll need the state on the server

#

Haven’t worked with WebRTC myself, main experience for me is with SteamMultiplayerPeer which lets me avoid having an explicit server since Valve handles the NAT punchthrough for me lol