Multiplayer Unity Game + WebRTC in 5 minutes

A Unity plugin for peer to peer games using WebRTC. Create a WebGL multiplayer game in 5 minutes.

Leon Do
3 min readDec 31, 2020

Disclaimer: This project has the ChainSafe family! ChainSafe is incredibly excited to have Leon join us as Head of Gaming. His Unity SDK is now publicly available on ChainSafe’s Github here as the Web3.Unity library, where it will continue to get developed. Please check out our announcement article to learn more

Overview

Social distancing has led us to find other forms of communication. Video chat, social media, and multiplayer games have become more than entertainment. It’s how we stay sane.

As these forms become more important, the tools used to build it must become faster and easier to use. Tools that can enable game developers to build their hyper-casual game in a weekend. Which leads me to a story.

My Multiplayer Experience

Having built a few single player games, I was ready to experiment with multiplayer. I dove into the Unity’s Multiplayer and Networking manual and found:

Note: UNet is deprecated, and will be removed from Unity in the future. A new system is under development.

I then looked into alternatives to find that it’s quite fragmented and spent many weeks learning the complexities of networking. The plugins were bigger than the game itself. It did not make sense to use a complex networking plugin for a hyper-causal browser game.

I just want two players to move on the screen!

Peer to Peer multiPlayer Plugin’ Play

As a gamer, would it be nice to share a link with your friend and start playing instantly?

As a developer, would it be nice to build a multiplayer game without paying for another server?

This project is to experiment with a technology called WebRTC.

Web Real-Time Communications (WebRTC) is a free, open-source project that provides web browsers and mobile applications with real-time communication via simple application programming interfaces

WebRTC is similar to websockets, but does not require a server. Think, your web browser sending data directly to your friend. No third party.

This method cuts costs and makes the network completely decentralized (if you’re into that).

The next step is to make it simple. The goal of this plugin is handle the networking stuff like creating offers/answers so you can focus on building the actual game. Simply drag and drop the script into the player Game Object and you’re done.

Alpha

This project is highly experimental and would love to get feedback. For more info contact us directly on Discord.

Stay safe and connected.

Photo by JESHOOTS.COM on Unsplash

Also, Read

Get Best Software Deals Directly In Your Inbox

--

--