How do I make a 2d game that's multiplayer?
-
As the title states, how do I make a 2d game that’s multiplayer? i’m trying to make my game have clones of the players that will act as other players.
-
@jd131111 You use the multiplayer extension, creaticode has an example and if you want something specific I can provide a demo (though my methods of using stuff can be a bit elaborate)
-
@tyller_ Okay, thank you i’ll try learning how to use it, if I need help, I’ll just comment on the forum about it
-
@jd131111 https://play.creaticode.com/projects/6613fb5b564fc287b0e8cfc2
is the link, I have a project if you want variables synced across all clients (my project is formatted like an api where you just use custom blocks that you drag into any sprite in your project, and those are just used to send formatted broadcasts to interact with it) -
@tyller_ How do I make a clone of the players model and make it go to the position of where the seconds player client, send it to the server, then send it to the first players client, updating the position?
(also, how do I make the players model appear on clients?)
-
@jd131111 This one is when you add a clone to the game with the add sprite to game as shape block, it will run the “when added to game” hat block as that clone which is then spawned on all clients, also it makes it so whenever a new player connects to the game, it will spawn that clone for them and run the “when added to game” on that client example below
(In this example assume that you set in the prepare for green flag hat block to create/join the same world, so everybody is connected to the same world)On green flag click /
Create clone of myself with id (username)When I start as clone /
Add this sprite to game as [rectangle]When added to game /
log to console (clone id)when the first player (lets say their username is “playerone”) joins, it will log on their client “playerone”
When the second player joins (lets call them “playertwo”) it will log in their console (playertwo’s console) the message “playerone” because the clone that the first player added to the game gets spawned on this players client and runs the when added to game block,the then both clients (playerone and playertwo) will log “playertwo” because playertwo’s clone is now added to the game (edit: and spawned on the other players client), I can make a demo project if this is too confusing (edit: you repeat this logic for all players, and a side note, the clones positions are synced when they spawn in, but to keep their positions in sync you have to use the method shown in the 2 player space shooter example by CreatiCode, where you rely on the sync set speed to move them)