Recently I’ve learned some stuff about multiplayer games on Gdevelop, thanks to this example made by GemDev:
I’m very excited to apply it on my small project. But there’s an issue I want to solve first and I found no solution around the web.
In the example, he used 2 different control inputs for the players, because if he uses the same input, they both would control both characters.
I dug the P2P tool on Gdevelop and it seems there’s no way to create a unique identity for peers, so that you could create a condition that specifies who is the peer for the control action.
I saw a topic here about this, 8 months ago, and no solution. Does anybody got one?
Thanks a lot!
Edit: actually, this is much more important than just allowing players having same input: if I can’t distingish peers, I can’t allow them to have their own camera, their own screen stuff. It’s just like a emulated local game…
Quite the contrary, it has one built-in: the ID system. You can for any given event see the ID of the person who sent it. I will usually do something kind of like this:
I make an initial player instance for the local player, and set the ID variable to “LOCAL” on it:
Then, for stuff that only affects the local player character, I put everything under a condition that will pick the Player instance with the local variable set to true.
I give incoming connections an object they are allowed to manipulate and delete that object when they disconnect.
I complete the events of the local objects to notify other clients when it was changed:
And finally, I add an event to receive those events and process them:
Disclaimer: those events are not tested and have just been thrown together for the sake of demonstrating how you can assign an object to each player. They may not show the ultimate way of doing networking, player controls, incoming connections handling, or a suitable full multiplayer template in general.
Hello, Buddy! Thank you so much for the effort on your great response.
I’m already trying to implement your tips on the exemple project. When I get some results, I come back and give my feedback.
So, I couldn’t make in your exact way, but I took your general idea and made it by another method.
If you are curious to see the project, you can download it here.
Thanks again! Now I’m going to implement three new things to my multiplayer system:
- Save Game: I presume it must be simple for singleplayer, but not for multiplayer.
- Custom room name: instead of using a weird code, it would be nice if the room creater could choose its name, like, myworld1234, although it can cause some trouble with equal names.
- Rooms list: I want to give the option of playing more than 1 world
If you have any tip or good content about those features, I will be grateful again!