Requirements for multiplayer pack

I am thinking I should have client events like onupdate() onheal() ondamage() oncollision() onorderchange() ondie() onerror() onroompurge() onroomready() onmessage() onturnbegin() onturnend() score() onpowerplay() oncounter()-- others?

Thus the server should have functions like update() heal() damage() collide() orderchange() die() error() roompurge() roomready() message() turnbegin() turnend() score() powerplay() counter()

We should have server events like onmove() onshoot() onslash() onpowerplay() oncounter() onquit() onclientjoin() onclientpart() onmessage() onturnbegin() onturnend()

Thus the client has functions like move() shoot() slash() kick() overpower() counter() quit() join() part() message() begin() end()

Here is the idea I have for a basic, skeleton server, part of which was taken from that might be filled in in the authoring tool, and default stuff may be added for physics (which is almost beyond my charter). I’m not sure of the license of Can be used in PlayCanvas, or will we have to roll our own?

var app = require(‘express’)();
var http = require(‘http’).Server(app);
var io = require(‘’)(http);

app.get(’/’, function(req, res){

function Multiplayer() {

Multiplayer.prototype = {
clientmessage: function(msg) { io.emit(‘servermessage’, msg); },
clientmove: function() {},
clientshoot: function() {},
clientslash: function() {},
clientpowerplay: function() {},
clientcounter: function() {},
clientquit: function() {},
clientturnbegin: function() {},
clientturnend: function() {},

io.on(‘connection’, function(socket){
socket.on(‘clientmessage’, Multiplayer.prototype[‘clientmessage’]);
socket.on(‘clientmove’, Multiplayer.prototype[‘clientmove’]);
socket.on(‘clientshoot’, Multiplayer.prototype[‘clientshoot’]);
socket.on(‘clientslash’, Multiplayer.prototype[‘clientslash’]);
socket.on(‘clientpowerplay’, Multiplayer.prototype[‘clientpowerplay’]);
socket.on(‘clientcounter’, Multiplayer.prototype[‘clientcounter’]);
socket.on(‘clientquit’, Multiplayer.prototype[‘clientquit’]);
socket.on(‘clientturnbegin’, Multiplayer.prototype[‘clientturnbegin’]);
socket.on(‘clientturnend’, Multiplayer.prototype[‘clientturnend’]);

http.listen(3000, function(){
console.log(‘listening on *:3000’);

Here is a basic implementation of a client, the skeleton may be filled in with the authoring tool. The jquery code comes from, and may be replaced. The rest is mine, and should be implemented. We’ll have to add namespaces to clean it up, but comments are welcome.
function Player() {

Player.prototype = {
servermessage: function() {},
serverupdate: function() {},
serverheal: function() {},
serverdamage: function() {},
servercollision: function() {},
serverorderchange: function() {},
serverdie: function() {},
servererror: function() {},
serverroompurge: function() {},
serverroomready: function() {},
serverscore: function() {},
serverpowerplay: function() {},
servercounter: function() {},
serverturnbegin: function() {},
serverturnend: function() {}
var socket = io();
socket.emit(‘clientmessage’, $(’#m’).val());
return false;
socket.on(‘servermessage’, Player.prototype[‘servermessage’]);
socket.on(‘serverupdate’, Player.prototype[‘serverupdate’]);
socket.on(‘serverheal’, Player.prototype[‘serverheal’]);
socket.on(‘serverdamage’, Player.prototype[‘serverdamage’]);
socket.on(‘servercollision’, Player.prototype[‘servercollision’]);
socket.on(‘serverorderchange’, Player.prototype[‘serverorderchange’]);
socket.on(‘serverdie’, Player.prototype[‘serverdie’]);
socket.on(‘servererror’, Player.prototype[‘servererror’]);
socket.on(‘serverroompurge’, Player.prototype[‘serverroompurge’]);
socket.on(‘serverroomready’, Player.prototype[‘serverroomready’]);
socket.on(‘serverscore’, Player.prototype[‘serverscore’]);
socket.on(‘serverpowerplay’, Player.prototype[‘serverpowerplay’]);
socket.on(‘servercounter’, Player.prototype[‘servercounter’]);
socket.on(‘serverturnbegin’, Player.prototype[‘serverturnbegin’]);
socket.on(‘serverturnend’, Player.prototype[‘serverturnend’]);

say I noticed that script tags weren’t shown when I included them. does that mean I can include javascript to be run on someone else’s browser? Not a good idea for a forum :frowning: Looks like it’s ignored. Good!

I think the next step may be adding functionality to the server, either for turn taking or physics, dead reckoning etc. what do people think should be next?


Just wanted to share some generic APIs I’ve worked with in the past for multiplayer. Maybe you ll get some architecture ideas from them as they are widely used

One is Photon Server

And the other one is Smartfox Server

The Valve / Source Engine documents are a great place to learn about designing multiplayer servers:

Say I started with the JavaScript client API for SFS2X. What other functionality would people want in a multiplayer server? See:

Hi guys,

I am a noobie here, but have been very impressed with with the PlayCanvas projects I have seen to date. Well done everyone!!!

I am very interested in seeing a multiplayer framework (or several to accommodate different styles of games) being utilised for this platform.

Just wondering what the status is on such a development. E.g., are there any examples of multiplayer games using play canvas etc.?



Hey @uqsbolla,

Check out Tanx:

(project link)

(play link)

It uses Node.js for the server and will definitely help you get started with multi player game development.

1 Like

Hello @yottzumm.

Are you interested in starting with a basic game, and working up from there? The Tank game that @vaios pointed out may be a good place to start. I’m just trying to get something up and working now but I’d love to support multiple players from different sites. Now the game will support two players (mainly to test the performance. . .but I’m a full screen type of guy :smiley: )

You can see my progress in another thread, “Wanted to share my progress” (Wanted to share my progress thus far).

We could add a team room, or melee mode, chat between teams, and obviously game updates. As we develop we could attempt to make it as generic as possible so that others could benefit from it.

Please let me know.


Sure, I can put down some other stuff and start working on a multiplayer engine again. Do you have a github repository or anything? svn is good. Or I could learn another DVCS

I guess I haven’t formally introduced my multiplayer framework because I don’t have a PlayCanvas game yet. Here it is, it’s like a tag game with a map. Would be cool if we could get some DEM data and apply it to these maps.

I’m using GitHub now, and used SVN for few years. Also ClearCase with an interface stuck in the eighties.

DEM data certainly would be easy enough. Would you mind waiting until I finish the current demo I’m working on? Finishing up the Menu, and adding GamePlay without networked multiplayer will take a few more weeks. Might go faster depending on what issues I stumble on.

No problem, I can find ways to keep myself busy.

1 Like

Actually, I was hoping that you wouldn’t mind testing the project as it stands now if you haven’t. Also, I’d like to start thinking about making the project a network multiplayer game as soon as possible. That is if you don’t mind.

I was talking about downloading the DEM data from USGS and incorporating into your project afterwards. A little selfish?

Also, I’ve added comments to the other “progress” thread. Which thread do you want to use? It would be better to work one, if possible.

Nice Job Yottzumm! Go get them! :smile:

That’s good. We can work on the current demo and add multiplayer features to it. I’m trying to get access to GitHub. Do I need to set up another GitHub account for PlayCanvas?

Well, where are we? We haver a server written in JavaScript that receives and sends motion events. It doesn’t have the full PlayCanvas Environment, I just stub out pc, pc.script and pc.script.create. However, I would like to start configuring the server like I do the browser stuff. What should I do to do scripting on a node server. I can look into this more, but I’m wondering if anyone is already running PlayCanvas on the server.

You are doing a fantastic job YOTTZ ( can i call you YOTTZ? ahah )