On Gotm your players can connect to each other using NetworkedMultiplayerENet or PacketPeerUDP without plugins or port-forwarding. Players connect through a unique invitation link that is generated when a player hosts a game. Try it out!
Press "Host" to generate an invitation link. Join the game by entering the link in a new browser window and pressing "Join".
The above game example uses NetworkedMultiplayerENet to connect players in a shared drawing session. See the source code for more details.
When you call NetworkedMultiplayerENet.create_server or PacketPeerUDP.listen Gotm automatically generates an invitation link. The link is shown in a popup, so it can easily be copied and shared with other players.
var peer = NetworkedMultiplayerENet.new() peer.create_server(8070) get_tree().set_network_peer(peer)
Accept the invitation by entering the link in another browser window. You can now connect to the host using NetworkedMultiplayerENet.create_client or with your custom PacketPeerUDP code.
var peer = NetworkedMultiplayerENet.new() peer.create_client("127.0.0.1", 8070) get_tree().set_network_peer(peer)
All players that have accepted the invitation have joined a shared virtual local network. This allows your game to send and receive RPC commands and packets to these players using methods like Node.rpc or PacketPeerUDP.put_packet. You can read more about Godot's networking and RPC commands here.
The easiest way to connect to the host is by using the special
var peer = NetworkedMultiplayerENet.new() peer.create_client("127.0.0.1", 8070)
This address always points to the player that created the invitation link. If you want to manually discover hosts with custom PacketPeerUDP broadcasting, that works too:
var peer = PacketPeerUDP.new() peer.set_broadcast_enabled(true) ### Only needed for 3.2 or later. peer.set_dest_address("255.255.255.255", 8070) peer.put_var("Sent to all players in network.")
Note: To send a packet to yourself with PacketPeerUDP you can use
localhost instead of