Multiplayer tutorial 2: chat room

Favourite 80 favourites
Tutorial written by AshleyOriginally published on 14th, March 2014 - 3 revisions

This tutorial assumes you have already read Multiplayer tutorial 1: concepts.

The easiest introduction to the multiplayer object in Construct 2 is a simple chat room. This only has to deal with connecting and joining the room, other peers joining and leaving, and relaying simple chat messages. Some of the more complicated topics like input prediction and lag compensation are simply not necessary since there is no object the player controls. These will be covered in the next tutorial, but for now we can focus on the basics and still produce something useful.

To get going, open the Example: Multiplayer - chat room example that comes with Construct 2. This can be found in the Select template or example dialog that opens when pressing File - New. While this example is already commented, this tutorial will explain it event-by-event in more detail, since some of the features take a little more explaining than is convenient in event comments.

Running and testing

To preview the example, you must run it from the first layout (F4). If you run the Chat layout directly, it will not be able to join the chat room, 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.

Comments

0
sakugoku 218 rep

Can I connect to another server? as local servers. If you can do it "wss: //multiplayer.scirra.com" instead of what I wrote. (I have personal edition)

Tuesday, April 26, 2016 at 11:19:56 AM
0
Poxnixles 568 rep

Anyway I can get all players in the same chat room to move to a different layout together, preventing further joins?

Saturday, April 30, 2016 at 3:17:44 AM
0
Poxnixles 568 rep

@ashley though also, I can't get seem to have others join the room I host?

Saturday, April 30, 2016 at 3:47:32 AM
0
Virenz 233 rep

I am getting a few errors, is it possible you could link a download link for the project so i can see what i am doing wrong? Thanks!

Monday, August 08, 2016 at 12:02:42 PM
0
Virenz 233 rep

I copied everything you did (including newline) but my text does not go to the new line :(

Monday, August 08, 2016 at 3:10:32 PM

Leave a comment

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