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.
Version 1.0 of the Inventory System is now available. It includes a few new additions since the closed beta: Lots of fixes found their way into this release as well:
Years ago I purchased a game dev bundle on HumbleBundle. Part of that was a sound library called Pro Sound Collection. It’s pretty comprehensive, whether RPG or FPS, there are sounds for a ton of use cases. I might as well use them for something. Luckily for me, the sound collection is pretty well organized. …
A smaller update. The inventory components now have custom icons to make it easier to tell them apart. This release also includes additional bug fixes:
This release contains the new Godot editor integrations. It offers an Item Library bottom panel that makes it easier to manage your inventory item types, and an inspector plugin that lets you edit items in a GGItemCollection. This also reduces the need for manually creating GGItemData resources, which simplifies item management at design time significantly. …
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.0 available
Version 1.0 of the Inventory System is now available. It includes a few new additions since the closed beta: Lots of fixes found their way into this release as well:
Audio Manager to handle the loading of sound effects in bulk
Years ago I purchased a game dev bundle on HumbleBundle. Part of that was a sound library called Pro Sound Collection. It’s pretty comprehensive, whether RPG or FPS, there are sounds for a ton of use cases. I might as well use them for something. Luckily for me, the sound collection is pretty well organized. …
Inventory System v1.4 available
A smaller update. The inventory components now have custom icons to make it easier to tell them apart. This release also includes additional bug fixes:
Inventory System 2 Alpha 2 available
This release contains the new Godot editor integrations. It offers an Item Library bottom panel that makes it easier to manage your inventory item types, and an inspector plugin that lets you edit items in a GGItemCollection. This also reduces the need for manually creating GGItemData resources, which simplifies item management at design time significantly. …