-
Notifications
You must be signed in to change notification settings - Fork 61
Multiplayer Support [AARD-2024, AARD-2021]
#1252
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
…s for active rooms
1d88f6c
to
75b1e5d
Compare
75b1e5d
to
7089985
Compare
[AARD-2024]
[AARD-2024, AARD-2021]
I agree that this isn't something we should worry about, and isn't a needed feature.
I don't remember the exact setup I had, but if I encounter it again, I will make sure to record the conditions. |
[AARD-2024, AARD-2021]
[AARD-2024, AARD-2021]
07d7f60
to
3134090
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks pretty good overall. I don't think one user should be able to remove another user's robot though, which is currently possible through the context menu.
Also, unexpected behavior happens if you configure your robot after spawning it. For example, I had two clients running and spawned a dozer in each, both of which were missing an ejector configuration. If I added an ejector to one and picked up a gamepiece, the other client would be spammed with "you need to configure an ejector first" toasts. I was able to configure the ejector on that second client to point in a different direction and have a different velocity, and when I ejected the gamepiece they went in different directions at different velocities depending on the client. I was only able to get this to happen once, but at one point after configuring the ejector on the second client, the first client lost possession of the gamepiece but was still considered to be holding it, so the robot could move around without the gamepiece but ejecting it shot the gamepiece in the direction of the ejector from where it was on the ground (even though the robot was across the field). When the ejectors don't match, the robot will often (after one or two ejections) get stuck and not be able to intake anymore.
77d71e8
to
99d70c6
Compare
Task
AARD-2021 AARD-2022 AARD-2023 AARD-2061 AARD-2067
Symptom
We want to support multiplayer
Solution
There were three sprints done to determine which technology / architecture would be used for multiplayer: #1198, #1220, and #1240, The latter of which we ended up choosing, read that spike PR for details on the architecture.
This PR introduces a new
MultiplayerSystem
, which manages all the peer connections, handles all the sent and received messages, and keeps data about which objects are owned by which peers, including its own client. Every tick,PhysicsSystem.update
sends either a collision or update message, as outlined in #1240.To avoid having to send field assemblies over network every time one is spawned, at first, only the assembly name is sent over, the receiving client searches for the assembly in its cache. If it doesn't find the assembly, the receiving client sends an assembly request message back to the first client, which responds with the full assembly.
To avoid any central stateful server (which peerjs is designed to avoid), joining rooms is done by encoding several hashes in the user id. This allows clients joining a room to easily identify peers with the same room id, verify that they also know the room id, and avoid exposing the room id to anyone who doesn't know it (and prevent people from enumerating rooms).
Verification
cd <synthesis>/multiplayer
bun i && bun run start
http://localhost:3000/fission?randomId=1
in two tabs. Click the multiplayer button in both. Press create game in one and copy the code, then paste it and click join game in the otherBefore merging, ensure the following criteria are met: