This blog post is licensed Creative Common Attribution Required v4.0.
One of the most highly demanded features for Construct 2 has been support for making real-time multiplayer online games. While we have supported WebSockets for some time, it has two key barriers to real-time multiplayer: the need to write a separate server, and the guaranteed in-order transmission using TCP. This can create head-of-line blocking and ruin the performance of latency-sensitive games, compared to UDP which can ignore dropped packets and reduce latency. With the arrival of Chrome 32 and Firefox 27, we now have a solution: WebRTC DataChannels!
WebRTC is a new browser feature allowing peer-to-peer connections. Whereas browsers typically connect to central servers to access content like websites, WebRTC is the first technology that allows browsers to connect directly to each other, without going through a server. This allows people to make audio and video calls directly to each other from the browser, as well as creating DataChannels to send arbitrary data, such as chat messages, or in our case, multiplayer game data.
Peer-to-peer connections have the advantage that you don't need to write or even host a separate server! Players can connect directly to each other. However if you would prefer to run a central server, you can still do this - a server is just a special kind of peer.
Peers still need to be able to find each other though, such as to determine each other's IP address to connect to, as well as working around any restrictions imposed by network address translation (NAT), a very common feature of home and office networks. For this a central server is still necessary, called the signalling server. It does not actually host any games - it just allows peers to find and connect to each other. As part of the new multiplayer feature, we are also developing a signalling server to help players find each other in Construct 2 games.
Currently only Chrome 32+ and Firefox 27+ support interoperable WebRTC DataChannels. However this also includes the mobile browsers and other Chromium and Firefox based platforms, such as node-webkit, Crosswalk and Firefox OS. Hopefully other vendors who have Chromium-based platforms like Blackberry, Amazon and Tizen will also be able to add support by updating the version of Chromium they use. Other browsers such as Safari and Internet Explorer do not have any support yet, but as with all new web platform features, hopefully support will arrive in future.
We are writing our own custom multiplayer engine to best suit the needs of Construct 2 developers. The intent is to make it efficient and responsive enough for latency-sensitive action games. The planned features include:
We recently put out a new stable update, r163, we plan to dedicate the next release cycle (usually around 6 weeks) to testing and further developing the new multiplayer engine. It is a large and complicated feature which can be tricky to test and needs to handle a variety of network conditions that happen over real connections around the world, so we anticipate it will take some time to get working robustly. During the beta test there may at times be restrictions on the available features (such as the maximum number of players in each game) to ensure stability before we scale things up, and the signalling server availability may be intermittent if it has issues during the beta test. Of course we hope that this will not be a problem at the full release, but please be aware that as it is all in beta that there may be issues.
We will initially make the beta version of the Multiplayer plugin available only with a license, so it will not be available in the Free edition. We will later consider adding a trial version for Free edition users to test.
Additionally, given the scope of the feature and the ongoing running costs, we are planning to introduce a low-cost subscription for the full version of the multiplayer feature upon its final release. This is planned to support extended features, including player logins and data storage (e.g. for players to accumulate inventory, achievements, ranks or experience points in a multiplayer game), leaderboards, location-based matchmaking, and possibly relay servers to help connect users who are behind extremely restrictive NAT and would otherwise be unable to connect. We do hope to support a basic but useful version for existing users with a license. This is still under consideration and is subject to change, but please be aware our priority during the beta is to test it is efficient and robust, and that we may make adjustments to the available features after the beta.
We are running an initial test of the multiplayer engine here:
Please give it a spin and see how it works for you! Note if you've run it before, it's been updated a few times - make sure it says 'Revision 12' in the corner, and refresh if it doesn't. The first user in to an empty room becomes the host, but if they have restricted connectivity you might not be able to join. If you have trouble joining, try one of the other locations, or pick an empty one and host yourself. (The locations are just separate rooms, to encourage people near to each other to join the same games, which should help reduce lag.)
We might run other tests, and we'll need your help to test them! There's nothing like the real-world Internet to see how it fares. If you'd like to get involved, follow our Facebook page, Twitter or Google+ page for announcements about upcoming tests. Note announcements may come at short notice.
This is a major feature and we're excited about what it will make possible. Many simple games gain a whole new level of engagement, excitement and replayability when you can play with other people online! Platformers, shooters, all-vs-all, co-op and more should all be possible. It's traditionally been extremely difficult to make effective multiplayer games, and we aim to make it easier than it's ever been with Construct 2.
Get emailed when there are new posts!