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'm trying to create a game where one player starts a server and others enter his IP address and connect to him. I managed to get it working for localhost and also for 2 computers at the same Wifi.

The problem is when I try to do it with my friend (who is connected to a different network) he can't connect to my server. This is part of my autoload script:

func host_game(new_player_name):
    player_name = new_player_name
    var host = NetworkedMultiplayerENet.new()
    host.create_server(DEFAULT_PORT, MAX_PEERS)
    get_tree().set_network_peer(host)


func join_game(ip, new_player_name):
    player_name = new_player_name
    var client = NetworkedMultiplayerENet.new()
    client.create_client(ip, DEFAULT_PORT)
    get_tree().set_network_peer(client)

Is something wrong with the code, router or am I just entering the wrong IP? I tried to enter IP from websites like whatsmyip and also ipv4 from command ipconfig.

Edit: I found a good answer here: https://godotengine.org/qa/65718/private-vs-public-ip-addresses but couldn't set up my router so I looked further. Found free hosting site for Godot games ( https://gotm.io/ ). Easy to upload but still can't figure out how to enable multiplayer. Any ideas?

in Engine by (330 points)
edited by

Found free hosting site for Godot games ( https://gotm.io/ ). Easy to upload but still can't figure out how to enable multiplayer. Any ideas?

That website won't provide hosted multiplayer servers (or a way to avoid port forwarding if you're hosting a server on your own PC).

Okay so I tried to do it with port forwarding (port 10567). Disabled all firewalls on windows 10. Also setup static IP on my computer and set the wifi as private. Still my friend (client) couldn't connect to me (server). Any ideas? I'll probably ask this as a new question though.

1 Answer

0 votes

You have to either port forward the host or use a virtual network, I use Hamachi to do this
you can get hamachi at (VPN.net) it hosts a virtual network that will trick games into thinking you and your friend are on the same local network.

by (14 points)

I solved it
It seems that we have to look closely at the IP of the PC directly in the ethernet state, there is the real IP while Godot, due to my bad configuration, throws me another IP so that it is already there
In addition to that we must give permissions to the app before exporting with godot
Internet and Access network satate
With that the connection between pc and android is successful greetings!

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.