Replies: 2 comments 1 reply
-
Also interested in this. I was thinking about using websockets with AWS Gateway API for the position etc. but collision detection seems pretty hard... |
Beta Was this translation helpful? Give feedback.
-
A good way might be to use WebRTC, but it can be a little complicated to get set up. Once setup, the communication is P2P which should be faster. I'd argue that you won't know the right approach before putting it together because each game has unique requirements. If cannon isn't deterministic, relying on it for the game state is a bad idea. I'm positive it isn't. I'm assuming both (or multiple) players exist in the same game world/level. Handle all collisions, physics and player navigation locally first, then broadcast the positions using an event stack. Those events are 'the game state.' This is a state-based reconciliation. There is also input-based reconciliation which also might be a good fit for your game. The most challenging part will be reconciling which game is 'correct.' The host machine can be used to reconcile the game state. If a player in the game is also the host, it is a massive advantage. Of course, you can always use a server to host the game, and players connect to the host, but then you need a server for every game. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
So yesterday I made a post about asking how can I make a online multiplayer game using r3f and I have already started working on it. My problem is that I don't how to send the other players position data through the server? I mean their position would be updating in game loop and it doesn't seem good idea to send data in game loop so what would be the solution here how it is generally done? Second doubt is that I'd be getting the data of position of other players but moving the physical entity using position will make them pass through other physical entities, won't it? Like if I use cannon js and I do api.position.set(data from server) this will make the players pass through walls and stuff. So what could be the solution for that?
Beta Was this translation helpful? Give feedback.
All reactions