0 votes

I a'm using Godot 3.1. Creating two player game, one player own and second player is server(other device player).

Now how to connect two player with live server network?

I a'm creating one demo of two player connect each other and it's working find in local server ip 127.0.0.0 and port 4242.

I see both Godot project demo but it's also work in local ip, demo link are below.

https://github.com/godotengine/godot-demo-projects/tree/master/networking/multiplayer_bomber

https://github.com/godotengine/godot-demo-projects/tree/master/networking/multiplayer_pong

asked Apr 15 in Projects by Shailesh dhaduk (21 points)

1 Answer

0 votes

Your question is a bit unclear. In your title you state that you want to connect two devices with a live server. So you're speaking of three devices or at least programs.

Inside your question you state the the second player IS the server. That would be a kind of peer to peer (P2P) network approach.

First of all. Godot offers some different multiplayer network options. You also can either connect two clients to a server (all running godot) or let one device be the server.

Second: Forget about localhost/127.0.0.1 (not 0). This is a virtual local address and only works when all software runs on a single device.

Third: There are multiple ways to connect two devices via the network of with another server. And there are also potential problems depending on what you want to achieve.

Classic Client-Server:
You can have a server software running on a hosted server. This server usually has at least an ip or even a domain/hostname mapped to it. The hosting package has to allow running custom software on it though. It is also possible to run such a server on an own device an configure your router port mapping and dynDNS so that external users can access the port+device from outside.
Some info about godot servers:
https://mrminimal.gitlab.io/2018/07/26/godot-dedicated-server-tutorial.html

Local network:
You can have both clients running in the same network. If the network allows two clients "speaking" to each other (often not the case in public wifi networks) then you can simply let one client be the server and access it via its local ip + port (such a local IP often begins with 192.168.).

Port mapping or UPnP:
If the router is (manually) configured the forward a port to the specific "server" device IP the client can connect to the dial-in IP of the server (this is the temporary IP that is assigned to the router on dial in) + port. Or the router can be configured via UPnP to do the port mapping (but not all routers allow this for obvious security reasons):
https://docs.godotengine.org/en/latest/classes/class_upnp.html
https://github.com/godotengine/godot/pull/18780

IPv6:
If both clients access the internet via IPv6 then they might both have world wide unique IPv6 addresses to adress each other. (As long as the router/firewall allows it).

NAT punch through:
In IPV4 networks there's a method to circumvent the portmapping/address dilemma which occurs with routers when both clients are in different local networks. You'll still need a hosted server + software to initiate the client<->client communication but the server won't need to route/proxy the traffic.
See this answer:
https://godotengine.org/qa/41903/establishing-peer-to-peer-connection?show=41908#a41908

answered Apr 15 by wombatstampede (2,015 points)
edited Apr 15 by wombatstampede

Thank your for quick give me answer.

First clear my question,
One app is Godot install in two devices (iOS or android) both connect with internet not a local network,
Now how to connect both device with server so one device move object on that time reflect in second device.

This point related any doc or source part or any link provide here.

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 How to use this Q&A? before posting your first questions.