0 votes

I was working on a simple multiplayer setup, and I just want to have it so when the server is created, it will send a signal to the LobbyMenu script which will add a new little box with the username in it.

func create_server():
var peer = NetworkedMultiplayerENet.new()
peer.create_server(SERVER_PORT, MAX_PLAYERS)
get_tree().network_peer = peer
print("Server created.")

I ran the game and the print("Server created.") ran, but apparently not the single because...

func _ready():
    Network.connect("server_created", self, "_server_created")
    Network.connect("player_joined", self, "_player_joined")
    Network.connect("update_client_player_list", self, "_update_client_player_list")
func _server_created(local_username):
    print("Server Created, Updating LobbyMenu")

The "Network" is an autoloaded singleton of the Networking script with the create_server() function. That print message in _server_created never shows up.
I guess I'm asking if I'm making some dumb syntax mistake, or if anyone has any ideas as to why its just...not going.

Godot version 3.2.2
in Engine by (18 points)

1 Answer

+1 vote

Use debugger with breakpoints, or add diagnostic print near LobbyMenu._ready, to see what actually happens (in which order).
Just a guess: it could be that LobbyMenu is not ready (and thus not connected to signals yet) at the moment you emit a signal.

Normally "dumb syntax mistake" won't allow to run a program. Runtime errors are shown in logs.

by (1,646 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.