0 votes

Hi, I am setting up a server/client environment in which the server can also be a player.

I set up the server like this:

var peer := NetworkedMultiplayerENet.new()
var result := peer.create_server(int(host_port), host_connections)
tree.set_network_peer(peer)

Later, when setting up the players I need to send some data from the client to the server, or, if on the server, from the server to the server (players are configurable/saveable by the client, like in terraria).
I am using "send_bytes" for this. On the server I get an error when I try this:

ERROR: Invalid target peer: 1
At: modules/enet/networked_multiplayer_enet.cpp:578

If I call "gettree().multiplayer.getnetworkconnectedpeers()" I get an empty list, which explains the above error.

So how do I go about sending data from the server to the server? I want to avoid having to put extra code in all over the place to do something different if the player is on the server.

Any ideas?

in Engine by (77 points)

I am not sure if provided networking layer supports this, but normally you can create a client/server connection within the same program. In server player application, try creating another NetworkedMultiplayerENet as client and create a connection between client and server.

Please log in or register to answer this question.

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.