Multiplayer tutorial 4: real-time game

Favourite 83 favourites
Tutorial written by AshleyOriginally published on 19th, March 2014 - 4 revisions

This tutorial assumes you have already read Multiplayer tutorial 1: concepts, Multiplayer tutorial 2: chat room and Multiplayer tutorial 3: pong.

The first tutorial covered the theory of how multiplayer games work and the way they need to be designed, using techniques like local input prediction and lag compensation. The second tutorial covered a practical example of a chat room, which dealt with practical use of signalling, connectivity and sending messages. The third covered the basics of syncing objects. This tutorial will now cover the final topics of designing real-time games, such as implementing the input prediction and lag compensation described in the first tutorial. This is an advanced subject; if you are not already comfortable with your knowledge, consider revising the prior tutorials. This tutorial also covers some of the same ground as the previous pong example again, which is worth revising.

To get going, open the Example: Multiplayer - real-time game example that comes with Construct 2. This can be found in the Select template or example dialog that opens when pressing File - New. As with the previous tutorial, the project will be described event-by-event in more detail than the comments already in the project.

Running and testing

As with the chat example, the real-time game example must also be run from the first layout (F4), since it needs a valid name entered from the Login layout.

When testing the tutorial multiplayer games, it's possible you will meet other people who happen to be running the tutorial at the same time. However users commonly go "away from keyboard" (AFK) and leave things running without attending to them, so don't be surprised if other people are present but don't respond to chat messages. If you don't happen to meet someone active, get a friend involved and do some testing with them!

It's also possible someone will already be hosting the tutorial but you won't be able to connect to them. If that happens, change either the game, instance or room name and you'll start a new game which you host yourself.

Share and Copy this Tutorial

You are free to copy, distribute, transmit and adapt this work with correct attribution. Click for more info.


drappdev 2,164 rep

Thanks Wsoukkachang, I have installed the latest r166 beta and can confirm my issue has been resolved by using the 'auto-join room', instead of 'join room'.

Monday, April 14, 2014 at 9:24:46 PM
mltreadway 6,214 rep

Very Nice! Thanks again !!! :)

Tuesday, April 22, 2014 at 4:41:51 PM
Haseeb Sohail 204 rep

I Need to pass the score fro host to peer what should i do ?

Wednesday, August 10, 2016 at 6:52:31 AM
LoseBiene 367 rep

Hello Ashley
I've got a little question....
Would you're game run on LTE or only Local by Wifi?
We tested it with our and your game and i'ts unable to connect the second Player to the Host when they aren't in the same network.

Friday, April 14, 2017 at 2:37:09 PM
vankizzle 17.8k rep

i have question
why always peer have lagged ??

Tuesday, August 22, 2017 at 10:31:32 AM

Leave a comment

Everyone is welcome to leave their thoughts! Register a new account or login.