Need more tutorials for multiplayer

Hello, there are no tutorials for multiplayer games, that should be useful, or at least a list of games to learn to. For that purpose would be useful to add to games releases a lists of tags ‘platform’ ‘single player’ ‘multiplayer’ ’ shoot em up’ etc. to use to track the projects that can be useful to learn.

Anybody in the community want to contribute one? The Developer Site (including the Tutorials section) is completely open sourced on GitHub. So if anyone has, for example, used node.js and engine.io/socket.io to network 2 or more PlayCanvas clients together, a write up would be awesome. :smile:

I’m in the middle of implementing websockets for the first time to create a multiplayer game. So far I’ve been spending about a week learning how to use and set up node.js and socket.io on a remote server, but have been making slow-yet-steady progress, and getting positive results (fingers crossed I don’t run into any dead-ends!).

My recommendation is for you to to start with this simple tutorial that teaches you how to set up a localhost connection between multiple browser windows (all within your computer), so you can chat with yourself. It sounds silly, but by the time you’re done you should have a solid foundation on how to communicate from browser -> server -> back to browser. You can then start working on a real server so it works across computers, which is what you really want.

Here are the tools that I recommend you use:

Node.js
Node.js is a JavaScript environment that runs on your server. Servers don’t typically run JavaScript natively, so you need this as a foundation before installing socket.io

socket.io (server side)
This is a JavaScript library that opens connections between the server and your browser. It listens to events, and broadcasts events to multiple users, which is the essence of a multiplayer game.

socket.io (client side)
This is the client side of the same library. It also listens and sends events, but it runs on your browser. It can only send events to the server, it’s up to the server to broadcast it to all users.

PlayCanvas
You can set event listeners from socket.io in your PlayCanvas scripts to update the game accordingly.

It sounds a bit confusing, so I made a neat diagram:

I hope this helps, and good luck!

Hello, yes this can be helpful, i think i would not have problems if i transfer all my archives in a pc here at office, since i have a fiber connection, the only thing that bother me is that the power lines here are not very stable and often there are power outage. So i’m asking, actually my archives are hosted on powweb, i don’t know if i can upload node.js on their servers, the site info says that external access to archives is restricted for security purposes, do you think I can uplad it on that server or I will have to set up a server on my pc? The problem is that the only pc available here for that purpose is a very old one so it will be slow.

I don’t really understand what you mean by transferring all your files and power-outages at work and all that. I feel like we might be getting off-topic there.

I looked into Powweb, and it doesn’t look like they provide node.js support. I started a conversation about finding cheap node.js hosting that you can look into, and you can make your own choice there. However, before you start paying for hosting, and uploading files to a remote server, you should figure out how to set up and run a node.js app on your computer, using localhost. Were you able to install node.js on your computer and take the intro to socket.io tutorial?

i already has an apache server set on my pc, i have to try node.js and socket.io, i will notify when i have some information :slight_smile: tnx a lot for the infos