Multiplayer tutorial 2: chat room

25

Index

Features on these Courses

Stats

42,880 visits, 163,453 views

Tools

License

This tutorial is licensed under CC BY 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.

Published on 14 Mar, 2014. Last updated 29 Apr, 2024

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

The easiest introduction to the multiplayer object in Construct 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 Multiplayer chat room example that comes with Construct. 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.

You can also start multiple previews yourself either by using Remote Preview, or holding Alt and clicking the Preview button to start another local preview.

You'll need to enter your own room name for the chat. This makes it unlikely that you'll accidentally join the same room as someone else, which could interfere with your testing.

  • 14 Comments

  • Order by
Want to leave a comment? Login or Register an account!
  • Hi.i love construct.but I have a problem .

    only when peers and host,s adsl are same, it works can you help me.

    oh. and sorry.Im not english and its hard to write it.but I cant do any thing else.

    sorry. and please answer my question.

    thanks for your awesome program:construct.

  • Aren't chatrooms not allowed?

      • [-] [+]
      • 1
      • Ashley's avatar
      • Ashley
      • Construct Team Founder
      • 1 points
      • (1 child)

      You can make whatever content you like with Construct. However due to moderation problems, chat rooms are not allowed in the Construct Arcade. You can however publish chat rooms anywhere else.

  • How did you get the tab order to work on this? I see that I can tab from NameTextBox (UID 2) to RoomNameTextBox (UID 13) to JoinButton (UID 3). I can't find this anywhere and all my google searches say it can't be done, that you can only tab in order of UID, yet you did it in this project. Please help!!!

  • Hi, I tried to export the chat template to Android Debug apk and installed on my phone and try to host a room. It successfully connected and created the room as host. But when I try to connect another peer using my laptop browser it says connected as peer but will be kicked eventually. Am I missing something? Can I use multiplayer on Android device? Is the multiplayer plugin for browsers only?

  • sorry, where i can find the link to download the archive?

    • "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."

  • Load more comments (4 replies)