Free up to 1MM monthly messages. No credit card required.
Connectivity puts the ‘multi’ in multiplayer gaming. When building out a multiplayer game, any aspect of the game that involves communication between two or more players, whether it be in-game chat or sync player position, requires a reliable and consistent connection between the users.
Any player that has experienced lag knows exactly what I’m talking about here. As a developer, how can can you ensure stable and secure connectivity for core multiplayer features?
In this blog post, we’ll walk you through some different aspects of multiplayer game dev that require a reliable real-time connection for a smooth player experience, and I’ll link you to specific, full PubNub tutorials and demos we’ve written for each one. We’ll take a look at:
Managing and syncing player position is a key element of multiplayer gaming. If a player swings his sword and moves, those actions need to be reflected in real time on every other players’ screen. In multiplayer game dev, this is known as lockstep, where the actions of all players sync in real time.
A simple method for managing multiplayer interaction would be to send the entire state of the world to every other user whenever an action takes place. However, this requires a heavy load, and makes the game sluggish and laggy. Instead, we can simply send an "add or remove" command to a common channel every time a user carries out an action. For more details on how to handle multiplayer lockstep, we have a multiplayer interaction tutorial and demo available here.
For lightweight games, multiplayer functionality and lockstep can be implemented fairly easily. Our blog post Lightweight Multiplayer HTML5 Games with melonJS gives a good overview of multiplayer support and communications. It includes a live demo, so open up two browser windows in incognito mode to check out the lockstep in action! If you happen to be a voxel.js developer (or a fan of Minecraft), we also wrote a DIY multiplayer Minecraft tutorial and demo, which covers similar territory.
For a large majority of multiplayer games, you need a way for users to seamlessly communicate with one another, and in-game text chat does just that. Basic text messaging is the core of in-game multiplayer communication, and especially for fast-paced multiplayer games, you need real-time speed and low latency communication. For a simple chat application, check out our tutorial and demo on building multiplayer real-time chat.
Once you have your core chat application, enabling users to send and receive messages, you can start adding features tailored to your game. For example, you may want Presence functionality, which allows users to see who is online and offline, or Storage & Playback, which stores and retrieves previous chat messages.
General multiplayer group messaging is one thing, but what if you want to enable users to privately request and send messages to other users? Building private chat into your multiplayer application is another great feature that you can build with PubNub. We have a private chat tutorial that shows you how to create private chat, send alert and request popups, and give you fine-grain control over access to channels within users' chat.
I don’t know about you guys, but I love statistics. And I love real-time, live-updating statistics even more. To build real-time updating statistics into your multiplayer game, you need to do two things. You need to modify your source code, then build a simple, scalable server infrastructure to serve the real-time statistics.
With thousands (or maybe even millions of users) out there, how the heck are you going to link them all up to play against one another? Will you match users randomly? Or, maybe you'd like to match them based on skill? Or, do you want to allow them to challenge one another?
How about all three?
When building out a game server, a common issue is managing the state of games and players together, and communicating those states to users, no matter what their platform is. A C# game server is a great way to start, and when combined with PubNub and a REST-esque model, you have yourself the start of a simple, scalable game server. You’ll need two primary units, a server and a game manager. To get started, check out our tutorial on building a C# game server.
PubNub makes it easy to build and scale multiplayer game features and functionality. Whether you’re using PubNub to power your in-game chat communication layer, or syncing player actions, PubNub ensures that your game will have the real-time speed and reliability you need to present a smooth player experience.
Dr. Joe Kvedar, Chair of the Board for the American Telemedicine Association, joins our COO, Casey Clegg, to discuss why...
Today, we are glad to announce that we are currently in the process of implementing ISO-27001 security standards.