Comments (6)
For anyone interested in doing something similar with WebRTC in the future, I resolved this by making the following edits:
# network-time-synchronizer.gd
-L121: var sync_result = await sync_time(1)
+L121: var sync_result = await sync_time(Program.game_authority_id)
# network-time.gd
-L299: if not multiplayer.is_server():
+L299: if not Program.is_game_authority:
...
-L335: if not multiplayer.is_server():
+L335: if not Program.is_game_authority:
Program.game_authority_id
and Program.is_game_authority
are simply variables set across the network when setting up my WebRTC mesh.
On my own WebRTC signalling and setup code, I added the following calls:
# webrtc_client.gd
func _handle_webrtc_peer_connected(new_peer_id: int) -> void:
+ if new_peer_id == Program.game_authority_id:
+ NetworkTime.start()
# webrtc_signalling.gd
func _handle_authority_webrtc_client_ready(peer_id: int) -> void:
~ Program.game_authority_id = peer_id
+ NetworkTime.start()
~ await set_game_authority_on_existing_peers(peer_id)
from netfox.
I've realized that all of the network configuration starts from NetworkEvents
, which doesn't get fired for me because I've rolled my own server-client connection with WebRTC.
I'm going to add the same hooks to my own GameClient
and GameServer
code and report back.
I'll also have to replace multiplayer.is_server()
with my own Program.is_game_authority
since every peer in WebRTC technically listens for and initiates connections.
from netfox.
Thanks for the detailed post @bryanmylee!
I've realized that all of the network configuration starts from NetworkEvents
I see you've also figured this out, so this note is mostly for anyone else reading 🙂 You can also manually start things by calling NetworkTime.start
. NetworkEvents is a convenience wrapper over Godot's multiplayer events, but you can skip that layer.
I think I can support your use case by making NetworkTime's authority configurable, but default to 1 as it currently does. So that way you would set the NetworkTime's sync authority to Program.game_authority_id
and be done with it.
By the way, do I understand it right that your WebRTC setup does not emit the usual events ( connected_to_server, peer_connected, etc. ), and that's the reason why the original NetworkEvents implementation did nothing?
from netfox.
@elementbound As far as I know, that's correct. connected_to_server
isn't emitted in a WebRTC environment since all connection nodes are peers.
peer_connected
is emitted, but unlike a traditional client-server model, it's not isolated to the server only and is emitted on all peers when a new peer joins the mesh.
I've essentially replaced:
connected_to_server
withpeer_connected(id)
whereid == Program.game_authority_id
, andpeer_connected
withpeer_connected
whereProgram.is_game_authority
.
from netfox.
Thanks! I'll try to cater a bit to this use case, both in implementation and in docs 🙂
from netfox.
@elementbound Actually, I think you can ignore this. I've realized that it's practically impossible to get a WebRTC client to work when it's deployed on a server, especially if it's behind a container network like Docker.
I'm basically abandoning this approach :/
from netfox.
Related Issues (20)
- Time synchronisation
- "Legacy Island" Foliage should be included in Gridmap HOT 4
- Remove clouds for double the FPS HOT 7
- Increase FPS by removing sky background HOT 5
- Investigate multiple RPCs being triggered instead of 1 HOT 1
- Add Static Typing across everything HOT 1
- Remove leftover link from NetworkTime
- Add StateSynchronizer
- Server-authoritative multiplayer without network-wide rollback HOT 8
- Netfox doesn't seem to work with RigidBody2D or WebRTC HOT 1
- RigidBody sync doesn't work properly HOT 12
- Inquiry about Support for Authoritative Client-Server Architecture buy running a Headless Godot Server (A game build runs on the server) HOT 2
- Use `node.get_indexed()` instead of `node.get()` for state and input properties HOT 1
- Setting up a Noray Instance HOT 8
- Multiplayer Moving Platform HOT 4
- Better docs for is_fresh
- Raycast shooting
- after_tick.emit runs before the tick
- using TickInterpolator to interpolate rotation results in a stutter during the transition between -3.14 and 3.14 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from netfox.