Godot Easy LAN
A downloadable asset pack
For more assets like this, follow my itch.io page!
This is a Godot Addon to easily connect devices on the same LAN network. Source-code is also available on Github: https://github.com/henriquelalves/GodotEasyLAN
How it works
This addon uses basic network setup by creating a 'Host' device that continuosly send UDP packets with it's own IP and a 'room password' for it's 'lobby'; the packet is sent to the 0.0.0.0 IP address of the router, which broadcast the packet to all devices connected on the same LAN. 'Client' devices will receive the packet and create a list of available hosts and their respective room passwords. When a Client connects to a Host, it uses the stored IP to create a connection using Godot high-level multiplayer API.
How to use
This addon only works on routers that allows hairpinning. This addon handles the creation and setup of Ǵodot's High-Level Multiplayer framework. The addon is composed of two nodes: a 'Host' node, and a 'Client' node. To connect different devices, you must setup a device to be a Host and the others to be Clients; after that, the Host has to start_broadcast to send to the Clients it's address information. A password is generated on the Host and sent to Clients, and should be visible to the players; to connect them, you should use connect_to_server_code on the Clients and use the password sent to the client as the argument (passwords are basically hashes of a Host IP Addresses dictionary). The Host should use stop_broadcast whenever it should stop sending the players its IP Address to start the game.
- setup on Host and Clients devices.
- start_broadcast on Host device.
- connect_to_server_code on Client device, using the hash received by the server code.
- stop_broadcast on Host.
This is a simple demo in which you must choose whether you'll be 'Host' or 'Client'; then, it estabilishes connection using the Addon. After players are connected to the host, it can start the 'game' by clicking Start, which will transfer all players connected to the game to a simple scene that synchronizes players mouse-clicks to move their Godot Icon.
All code and assets are under MIT license.
Click download now to get access to the following files: