WebRTC in Multiplayer Games with com.unity.webrtc

It looks like there has been a lot of progress in the com.unity.webrtc repository and the examples and videos on Youtube mostly show possibilities for audio and video streaming.

However, I can’t find any tutorials and examples or open-source multiplayer games based on com.unity.webrtc, which is a bit surprising.

Why does this not exist yet? Is com.unity.webrtc not suitable? Are the latencies too high or is it too unreliable? Or is it just that no one is doing it yet?

Best, grizzly

1 Like

Perhapse PUN earns them revenue and they don’t wish to disrupt the status quo.??

I wish someone would create a basic internet multiplayer example showing how to build a true PTP game with WebRTC.

The problem with building a multiplayer game with P2P is to sync the game state between players.
If there are more than 2 player it’s even more complex.
Since you can use hosted game there is no point to use it on PC (has stable address).
It’s probably more valuable on mobile BUT the connection is unreliable.

And if you want to setup environment for WebRTC, you first need a Signaling Server, a Web Socket Server
for exchanging the connection info (like IP) between peers before the peers try to connect to each other
(otherwise, how do you connect to an unknown IP?)

Then you need STUN/TURN servers for peers to “find their actual IP address”.
This is really complex not gonna go too deep.
In short word: because there could be firewall, private network and etc… that hides the true external address (where other device can see your device) so you need them.

So, setting up the environment is already harder than just hosting a server as you can see.
WebRTC is useful when you want to connect unknown IPs and/or stream data P2P without relay (or the video stream just fills up the server bandwidth) but it is not reliable, sometimes, you still need relay.

AFAIK, Discord use WebRTC for easier establishing connection and utilizes WebRTC’s built-in video/audio processing functionality but with relays to improve reliablity.

2 Likes