Full round-based multiplayer game with Photon

  • 14 favourites

Index

Attached Files

The following files have been attached to this tutorial:

.capx

photontutorial.capx

Download now 184.34 KB

Stats

6,694 visits, 18,939 views

Translations

This tutorial hasn't been translated.

Tools

Introduction

Hello everyone,

in this tutorial i want to introduce you into using the Photonplugin for Construct 2 from ExitGames. We gonna create a whole working game (very simplified of course) which covers following points:

Basics

- Where to download and install Photonplugin

- Create a realtime app on the photon website that represents your server

- What's the difference between Scirras and ExitGames Multiplayer Plugin?

Local - Functions

- Create a debug log for a better overview

- Create a "CreatePlayer" function

- Create a "ResetRound" function

Multiplayer - Connecting, join and leave

- Preparation

- Add error catch

- Connecting to the lobby

- Connecting to a random room or create it if it doesn't exist

- Leaving a room by pressing 2 on the keyboard (for testcase)

Multiplayer - Handle player join and player leave event

- Preparation

- Create player objects on one authoritative player locally (Master Client)

- The Raise event explained

- Destroy player data and objects of the leaving player

Multiplayer - Handle object creation

- Send the Master Client data to all players to tell them where they can create their own local copies of all player objects

Mixed - Game relevant events combined with multiplayer

[L] = [LOCAL]

[M] = [MULTIPLAYER]

- [L] Set a position where to go and where to shoot and tell it to every other player

- [M] Handling the goto and shoot positions && Master Client starts the round

- [M] Start the round, "let them body movaaa"

- [L] Use rex_moveTo to determine that players arrived at their positions

- [M] Master Client tells everyone that players arrived and the fun begins!

- [L] Handle the impact of bullets on players

- [M] Master Client decides the real impact state and informs players

- [M] Players destroy the objects based on Master Clients decision

- [L] I want and end of all of this!

- [M] Okay guys, battle's over. For now...

Thank You

- The bitter end...

-> A capx file was added. Fully commented and ready to use. Remember to put you AppID in the Photon object.

Basics

Where to download and install Photonplugin

Visit the official photon website here.

On top hover on the blue realtime icon and click on SDK's.

On the next page select the drop down and choose Scirra. The photon plugin for Construct 2 will appear and you can click on download.

You will be prompted to create an account what you actually NEED to do. So just go ahead and create an account.

After downloading the photon plugin .zip file open it and extract the files photon.cs2addon and optional photon-chat.cs2addon. Open up Construct 2 and drag and drop those two files into Construct 2. A dialog appears asking you to confirm installation of the plugins. Allow that and you will be done!

Create a realtime app on the photon website that represents your server

After logging in go to your dashboard on top and click on realtime

Next step is to create a realtime app. Click on Create a new Realtime App. You simply need to enter a name and that's it. If not just fill out the rest as you wish. You should see something like this after:

What's the differences between Scirras and ExitGames Multiplayer Plugin?

Scirra's multiplayer plugin runs on a peer-to-peer base while photon is running a "dedicated" server handling all the events. The big advantage of the Photoncloud is that if a player disconnects the game is not stopping. In Scirras plugin one player becomes the server and if this server goes down everyone else will go down with it :) As a better explanation i made this simple graphic

  • 0 Comments

  • Order by
Want to leave a comment? Login or Register an account!