I need help with creating multiplayer to my game I have followed the instructions from the actual tutorial down till the point where you start up your game and the server log on glitch should say Client Has Connected but whenever I start it up nothing of sorts have came up I got to the point where the server was up and I even did https://cdnjs.cloudflare.com/ajax/libs/socket.io/3.1.1/socket.io.min.js version 3.1.1 but the newest is 4.4.1 should i use that version to get the ok from the logs to the point where it says Client Has Connected or should i still follow the tutorial for that also im not sure if im doing the code right should it look like this?
also here is my game to see if i did the code right or if you need edit access
Hi @Jack101 and welcome,
From what you’ve shared I see that you placed your code outside any script method. That means that the code may execute before the socket.io library is loaded and available.
If you check the original tutorial project you will see that the code is being placed inside the
Given your server is up and running, I think it should work then.
well thank you @Leonidas but it did not work I still see no message that says client has connected but is the url all i need to put inside or is it different than that
i put the newest i saw for packages in the server does it need to be the old version?
You could fork this link over here, and you’ll easily have what you’re looking for, I find that way more useful than just coding it manually, personally.
would all i have to do is put my server URL inside the code
not necessary, but if it’s required, you can obviously always change it, it’s really your choice
ok well thank you. Is there anyway where I could just copy all the coding and put it in my game or will i have to stick with this project and build from scratch?
I’m also going to jump to the conclusion that because you only pasted that one line, it’s probably not gonna work, compared to @Leonidas’s example where it actually initializes the actual thing, rather than just connect and leave it at that.
well you can just take all the assets from the game and repaste it into the fork, or copy and paste the code into ur existing game, either way MAY work.
ok well thank you very much ill be back in about 5 minutes and tell you if it worked or not
no problemo, keep on doing you!
so i kinda worked i did everything the other one had copied the code and put it in my game put when i would open a new tab nothing was there but when i would enable the “Other” character it would appear but would copy the exact moves the player made and would copy but in the other tab it was the same thing just on a totally new game kinda weird but ill see what i could do in the other one.
but the copier was the actual player moving not another player so just AI doing exactly what you do
I think thats one of two things:
Socket.io may be confusing two clients with the same IP?
- Maybe the other entity is coded to do the same as the player, I think you’d have to check with the Player script if that were the case
ok i just froked the game and put my charcters into the game and it WORKS!!
Thank you for the help ill put the game here in a little bit try it out its really difficult as to my knowledge about 50 people played and only 2 beat the first level also you cant move mid air thats what makes it so difficult
how do i edit the main text so it can say solved kinda new here sorry.
Click on the pencil icon at the top of your created thread to edit its title.
Suggested text to be added would be the strings
[SOLVED] Help with setting up multiplayer on my game