Creating network connections with Godot is simple — as long as you have the other party’s IP address, and there’s no NAT gateway involved. Unfortunately, that’s exactly the problem in most cases. You don’t know the other party’s IP, and these days, just about everyone is behind a combination wifi router/gateway/firewall with NAT.
Conceptually, NAT hole-punching is pretty simple, and this video explains how it’s done with just netcat.
In a nutshell:
listen on a particular port (e.g. 50001)
nc -u -l 50001
echo ‘hello’ | nc -u ipaddr 50001
echo ‘hole punch’ | nc -u -p 50001 ipaddr 50002
third party exchanges ip addresses
Putting it all together, player A (hosting a game) would require the game to connect to the directory server.
The directory server would list the game as something a player can now connect to.
player B (client who wants to join) will tell the directory service that it wants to connect, and will send its info
The directory server forwards the information to player A (host), player A will then send a packet to player B, and respond to the directory server
The directory server will then tell player B to go ahead and connect to player A.
Player B should be able to punch through to player A
With Godot, the connections from client to host would use ENetMultiplayerPeer.create_client(), which can specify the local port.
A new version of the Inventory System is available with more multiplayer-related features. The Multiplayer Interaction Demo can now run in multiple modes, through two separate implementations of the Character scene: The simple character scene leverages the MultiplayerSynchronizer and can either let the client have authority and move the character, or have the client send …
The latest version of the inventory system is available and includes refinements for the interaction demo and the main tour. New features: We’ve also got a handful of bug fixes:
Godot Engine is an open-source game engine. With the 4.0 release on the horizon, it’ll gain quite a bit of attention. And it’s an engine worth keeping an eye on. Internet Gaming. Serious business. Game development is serious business. The global gaming market size was 203 billion USD in 2020 (per fortunebusinessinsights). It is predicted …
Creating a UDP peer-to-peer connection
Creating network connections with Godot is simple — as long as you have the other party’s IP address, and there’s no NAT gateway involved. Unfortunately, that’s exactly the problem in most cases. You don’t know the other party’s IP, and these days, just about everyone is behind a combination wifi router/gateway/firewall with NAT.
Conceptually, NAT hole-punching is pretty simple, and this video explains how it’s done with just netcat.
In a nutshell:
Putting it all together, player A (hosting a game) would require the game to connect to the directory server.
With Godot, the connections from client to host would use ENetMultiplayerPeer.create_client(), which can specify the local port.
Here’s an older example of a signaling server: https://github.com/Faless/gd-webrtc-signalling/tree/master
Related Posts
Inventory System v1.14 available
A new version of the Inventory System is available with more multiplayer-related features. The Multiplayer Interaction Demo can now run in multiple modes, through two separate implementations of the Character scene: The simple character scene leverages the MultiplayerSynchronizer and can either let the client have authority and move the character, or have the client send …
Inventory System v1.5 available
The latest version of the inventory system is available and includes refinements for the interaction demo and the main tour. New features: We’ve also got a handful of bug fixes:
Inventory System v1.7 available
A couple of corrections and a new feature: Bug fixes:
Is Godot is the Linux of Game Engines?
Godot Engine is an open-source game engine. With the 4.0 release on the horizon, it’ll gain quite a bit of attention. And it’s an engine worth keeping an eye on. Internet Gaming. Serious business. Game development is serious business. The global gaming market size was 203 billion USD in 2020 (per fortunebusinessinsights). It is predicted …