Hello, I’m developing a P2P multiplayer game in godot with WebRTC, I already achieved to sync players (RigidBodies2D) and all that with the multiplayer synchronizer, but I’m having problems on finding how can I sync an non-player object like a ball, it’s also an RigidBody2D, and another question is how can I make a score system for when the ball enters a goal for example? Keep in mind that my game will be played with more than 2 peers. if anyone can help me I’ll be so glad
I’m using Nakama as a signalling server with WebRTC
P2P is always tricky because one peer needs to be the authority of non-player objects.
My suggestion would be to make the host own those objects. Add the ball on the host along side a multipleplayerspawner. The ball will have its own MultiplayerSynchronizer in its scene to update the clients version.
For the score system you could use a auto load Singleton, or a static functions on a global class. When the ball enters Area2D it will signal the score system Singleton. And that will RPC all the peers the new score to display. I would suggest the host should determine when a ball enters the goal.
Man, thank you so much, I was a bit confused about who I needed to give the authority, since I don’t have a main server/main peer, so I was wondering if I give the authority to the host would be a bad idea. I will try making a system to set the authority always to the first person who joined, if that one lefts it will change to the second one that joined. thanks so much for answering <3
I do have a question for webrtc, there is some game instance that creates the server? I think whoever this is should be the authority, but maybe I don’t understand the webrtc packet peer?
I guess if you use this then I think this may be part of the solution.
But I feel this moves away from the P2P ideology. Although with out making it super complicated, a physics based game doesn’t seem compatible with a p2p game imo.
Well, I’m creating a “clone” of a popular game called haxball, its made with WebRTC and its P2P , shouldn’t be that hard to recreate, I’ll take a look on this create_server method later, thanks for sharing.