0
\$\begingroup\$

I'm in the process of making a physics intensive multiplayer game. Naturally I use a UDP to transfer packets regarding rigidbodies between client and an authoritative server.

However non-essential packets I'd prefer to use a more reliable connection like WebSockets. This would be for things like voice chat, text chat, scoreboard, etc. It also seems the be a nice approach to checking if the client is still connected and if not, stop sending it UDP packets.

I'm actually unable to find use cases of this dual connection approach online and I was wondering how this is typically handled in similar games. Is it very far fetched or unconventional?

Another question would be how far do I take relying on the WebSocket connection? Lets say for managing remaining bullets in a guns magazine, would it be better over UDP or WebSocket?

I feel like WebSockets would be best in this case because if the bullet was successfully spawned and the server needs to remove a bullet from the client's gun's magazine, if that packet doesn't arrive at the client, then they shot a free bullet...

The UDP equivalent for this scenario would be to always send the client's magazine state as packets and the client just updates it's magazine whenever the packets get to them. My concern here is overloading the network traffic data that might not have even changed...

\$\endgroup\$
2
  • \$\begingroup\$ Did you try implementing your solution? Did it work? If it ran into a problem, what specific problem can we help you solve? If it works with no problems, then what does it matter whether it's a "typical" solution or not? \$\endgroup\$ – DMGregory Oct 23 '19 at 19:30
  • \$\begingroup\$ Haven't had issues implementing the solution. So I guess I don't have any problems, I've just realized that there are other ways of doing non-essential network traffic and that I might be over engineering my netcode infrastructure. \$\endgroup\$ – Fanus du Toit Oct 24 '19 at 14:03
0
\$\begingroup\$

In 2020 having two connections for different tasks - it's not a problem at all. But managing a game state with two different protocols and connections - is not a very good practice.

UDP will clearly work faster. If you will manage game state with UDP and WS - you can quickly get in some situations like "Player shoot before you get any message about its magazine state".

I'd recommend using UDP for all gameplay relates when speed is most important. Reload, move, physics, shoot, player positions.

And use WebSocket for side information. Like chant message, ranking, menus.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.