Real Time Multiplayer Tutorial

Hey guys,

Trying out the editor and working through a tutorial.

First of all, this tutorial feels incomplete https://developer.playcanvas.com/en/tutorials/real-time-multiplayer/

If you follow the instructions perfectly, you do not end up with the same product as on the above linked tutorial. The images seem outdated from the editor now.

Another things to note is the example in the above tutorial isn’t multiplayer. I’ve opened that page up on multiple browsers and computer and have yet to see more than 1 capsule show up.

Anyone happen to have a working version of this tutorial that they could share? I’d love to see a working version!

Cheers

2 Likes

Hey Dane,

So I’ve actually made a multiplayer game with PlayCanvas for Ludum Dare a while ago. I remember trying to fix that tutorial but it’s hard without having access to the source project and the server.

I think the problem here is just that PlayCanvas is running on https but the server is on http, so browsers block that by default.

Here’s a version I just threw together that should be working.

https://playcanvas.com/project/526224/overview/real-time-multiplayer-example

The server is running here:

You can make a fork of it yourself so you can edit it/restart it as you please. I expanded on it slightly from the tutorial to make disconnecting and deleting players work.

I’ve also written a more in-depth tutorial on how to set up multiplayer with Socket.io that, while it’s not specifically for PlayCanvas, it’ll give you enough background to know where all the pieces need to go:

We could also try just improving the one on PlayCanvas if you tell me what specifically you got stuck on if you get it working after looking at my version.

2 Likes

Thanks for the tut @OmarShehata! I will be looking into it for sure :slight_smile:

I am also following the same tutorial but am getting errors fairly early in (please see attached photo).

https://playcanvas.com/project/728722/overview/multiplayer-fork

I think I found out what my problem was.

In the instructions it says to copy and paste the content from here https://raw.githubusercontent.com/socketio/socket.io-client/master/dist/socket.io.js into the socket.js script file.

When I forked your PC multiplayer project and cloned your Glitch project everything worked fine but when I copied and pasted the above code, it stopped working. That’s my guess anyway.

I also see that I did not paste the code into the correct place here I also tried it the same way as you have done it (the correct way) and it still gave me the same errors.

I suggest following the tutorial more carefully as I used this tutorial word for word just last week successfully, including the raw github data for socket.io.js. I actually thought it was such a clear tutorial that I saved it to my google drive hahaha

Edit: Also your issue is that your socket.on functions are not inside the io.sockets.on(‘connection’) function, as that is where the reference to socket exists as a local variable.

1 Like

Thanks, both of you. Would either of you two consider mentoring me? As in paid mentoring over Zoom or something? (I have it working now by the way. I just can’t see the other VR player when I have both Quest2s connected )