This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

i found this template for 2d multiplayer but it is made to work with only 2 players. what would i do to make it work with more players? i would like to have it spawn players based on how many people i have in a lobby (so if i have 2 players it would spawn 2 and if i have 5 it would spawn 5)

this is the template:

in Engine by (12 points)

2 Answers

+1 vote

By simple looking at it, it's not prepared for dinamically add players, but you can try a few things:

First, add a list to the lobby to show connected players, and to avoid directly start the game after the first joined, an start game button.

For this to work, in the lobby script, trasnfer the game start capability from "player connected" method to the new "on start game button clicked" method you will create for the start game button, checking that at least 1 player joined the server.

And in the "on host pressed" method change the value that limits the peers connected, this line:

var err = host.create_server(DEFAULT_PORT,1) # max: 1 peer, since it's a 2 players game

Then in the stage scene and script, remove the player 2 in order to create it dinamically in a new method, one for each peer connected to server.

I'm sure I'm avoiding some details, but these are the basics.

by (327 points)
0 votes

i've used some stuff from bomber multiplayer demo and i think i managed to make it work

by (181 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.