One player object for peer-to-peer multiplayer game

Is it possible to have one sprite object for player and for example 4 players that will use it if that makes sense?

For example, 4 players connect to each other, and when host clicks “start”, every player will use “player” sprite object, but also be able to see it’s opponents who use that object. Ah… idk how to explain this.

You can create and ID (via object variable) for the object then assign each player an ID. Below is a quick example using the online editor.

Two instances of the same players object.

The player object has a variable, each instance on the scene has its id set (1 and 2)

Map the controls for each player and move based on the player_id. (Note the repeat for each instance is players, online editor makes it say {objectName}.

Test it here: Faint Giraffe | Play on

1 Like

Hi, thanks for your reply but that’s not what I was looking for. I don’t want two players to play on the same screen with different controls. What online multiplayer solution where all players use same controls.

Now, I “hardcoded” this example just to show what I need, and it does work, but I need this to be able to work with more then two players. Idk how exactly to do that. I was thinking about givin each object instance ID of the connected peer, and checking that to move one specific enemy but I’m not quite sure how to do that.

Video Preview:

This may help you a bit: [solved]Sync entity positions over P2P - #2 by arthuro555

In case you are interested, I am building a framework for making multiplayer games in GDevelop easily:

Thank you, I just can’t figure out what are the children every structure uses in that example in order to create those. IncomingPayload for example. I added these to EnemyPayload judging by the actions but I don’t know for others.

PS: THNK Looks promising! I will definitely use it when tutorial appears on your website.
PS2: I did opened example provided in that topic, but even there there’s now scene variables provided.
Anyway, this is my progress so far (Yeah, I started recreating all events into my game)

@arthuro555 Okay so I did managed to make it work with the way provided on that link but the only issue I had was that my objects were blinking non stop. So I tried this new way below, and it just doesn’t want to work. It does creates enemy objects but they won’t move when player is moving.
For example. if PC 1 is moving, on PC 2 enemy will stay still.

Any tips on how to make this works?