[SOLVED] How to do multiplayer?

I have a FPS experience i want to convert it to multiplayer experience and i want to start the server locally using node.js. Is there is any tutorial available because i tried 2 tutorials they’re not working for me.

Hi @Vivek_Chaini,

Which tutorials have you tried? Did you get any errors?

Hi @Leonidas I tried these two first one is Real-time Multiplayer with Colyseus | Learn PlayCanvas and this one is not working for me then I started using photon one Real-time Multiplayer with Photon | Learn PlayCanvas this one is working but when Its showing error with with ammo.wasm files so basically if i try to implement the photon multiplayer in my project which has a rigidbody player with collision it gives this error when i try to play it.

(This is when I tried the photon tutorial)
Here is my project link PlayCanvas | HTML5 Game Engine

1 Like

Hey @Vivek_Chaini,

We’ve just recently updated the Photon tutorial to address this issue. We previously linked to an experimental Photon WASM library that had incompatibility issues with other libraries, like ammo.js. We have now updated links to show the Photon JavaScript SDK, which does not suffer from this issue.

As for the issues in Colyseus, what exactly did you encounter?


@poliveira Can you give me the link to the updated Photon tutorial? And about the Colyseus I was not able to connect to the server for some reason i might not have followed the tutorial properly.

The Photon page has been updated here: Real-time Multiplayer with Photon | Learn PlayCanvas

If you are running into issues with Colyseus, check this or other threads around it: [SOLVED] Colyseus is not working with Playcanvas - MultiPlayer Demo not work

@Leonidas @yaustar @poliveira I was trying Colyseus again and setup server the locally. I tried the first command “npm init colyseus-app ./playcanvas-demo-server” It asks me to select a template when I select TypeScript(recomended) it says the following error

Is the ./playcanvas-demo-server folder empty (also empty of hidden files and folders)? If not, delete it’s contents and start again

1 Like

@yaustar the folder is empty still getting this error

Including hidden files and folders? Might be easier just to delete the ./playcanvas-demo-server folder itself

Yea i have tried to do that deleted the folder itself but and try that command again but still its shows the error

I’ve just tried the command and it works fine on my end :thinking:

A bit difficult to diagnose without being at your computer I’m afraid

I am not sure what’s going on here :smiley:. I tried deleting the folder many times. Can you confirm one thing do we have to do this on Administratoe side of pc?

@Vivek_Chaini It looks like you open the command prompt in your users directory on windows. This is the default when you open a command prompt. You could try the following. Create a directory under your C: drive. Open a command prompt which will default to C:\Users…> Navigate to root. Then cd to your newly created directory. If npm is installed correctly you can execute the the npm init command as shown above here. Also, there is a log that is generated on failure. It would be nice to see that as well.


I tried what you said still not working here is the log @Tirk182

@Vivek_Chaini It looks like you are still using the C:\Users…> location. Do you have a log from the other location. Also,

npm init colyseus-app ./playcanvas-demo-server <<<You could change this name. It’s just the folder for your build.

1 Like

@Tirk182 This is not wroking as I dont have access to certain folders. However I am trying to do multiplayer using Photon and its working fine. But the players are showing very weird behaviours(like when player1 moves we can see that another player2 is following player1 whereas player2 is not moving at all there is some problem with the movement) Can anyone suggest what is wrong here in this project PlayCanvas | HTML5 Game Engine and how I can fix it?
Here i’m not using pointAndClick instead im using fpscontroller script @yaustar @Leonidas

@Vivek_Chaini I ran your code that you have in the link above. Seemed to handle FPS controller fine. How are you launching the second instance of the game? Here are the steps I used to test it out on the same machine.

1.) Loaded project above in edit mode.
2.) Clicked launch and created a new room and moved my player to another point on the plane.
3.) I right clicked on the Editor tab in my browser and selected duplicate.
4.) I clicked on the duplicated tab which shows the editor.
5.) Clicked launch and then joined existing room.

I found that when I was moving one player it was best to escape out of that game before I went to the other tab. There was something that was a little fishy about the position of each player at times but they did not follow each other around.

This is what I see on FPSPlayer entity.

Maybe there is something going wrong here.

1 Like

I did the same thing what you did and also another user joined from different machine the movement was jittery(if we see from player1 perspective player2 movement is jittery and vice versa). And in the FPSplayer entity if you’re talking about the script its disabled. I am not able to figure out what’s going on in project.

@Vivek_Chaini I think I was able to see the issue. The FPS camera was not set inside the player. Here is your original.


Your camera is set in root which is giving you just an overall picture outside the player. I deleted the camera in root and added a new camera inside the FPSPlayer.

I then made the following change to FPSPlayer.

Let me know if this fixes it for you. Actually there is also some other issues with player. You probably have to make the same changes to it as well @poliveira? This is what I did to player that is disabled.

The point and click script needs to be deleted so the players don’t join each other when they get close. This will be active in your Root.