Godotovchans! Good people!
I want to consolidate the thoughts and seen in the guides material “about multiplayer”.
All poked, thought and did not fully understand how exactly creates a network game without using Steam, Web and other platforms.
Only good old local in Radmin, Hamachi. I want to start trying P2P for there are no resources to install their own servers or even more forces to sort out the connection with Stim, it is already self-same time.
Very, straight I will be very grateful if you find an answer to my question.
I am grateful for the answer in advance, bless you the Spirit of the Machine.
You kinda need a server, also it can also be a client. Just one of the peers has to keep track of stats, connected clients and a like. The godot docs have some goodies for you
Îf you want to do something old school in multiplayer you don’t need a third party like Radmin, Hamachi. You only need a host and client. You use the same game for every player. One player should be the host, its godot game will listen to a port you configure, and then other player can connect to its game using its computer ip (if you are on lan you just need to open the port on windows (by default it should be blocked)). Yuo can also doing it online with some port forwarding on the host box.
You can checkout this tutorial to understand basics of host/client code on godot
It explains the basics well, but i advise you not to copy paste his code it’s not so good
Also like soupstitute said you should checkout the doc also it’s really well written.
About the port blocked and port forwarding, just start looking on google i think with those keyword and you will find tones of stuff explaining how it works. Also chatGPT explains it well
Operating without a server nowadays is extremely difficult. Most internet service providers (ISPs) block UDP ports in many countries, preventing direct connections. In Brazil, for example, opening ports and gaining full network control requires a business-grade internet plan with a fixed IP and dedicated bandwidth, making access more restricted and costly. This situation complicates the deployment of self-hosted services and local solutions.
Probably a bit overkill and sub-optimized (because not developed for gaming) but there are some easy-to-use P2P solutions that offers NAT transversal out of the box such as Iroh (an IPFS implementation in rust, GitHub - n0-computer/iroh: IP addresses break, dial keys instead. Modular networking stack in Rust. · GitHub ) or hyperdht/hyperswarm (javascript libs that offers super easy P2P connections and work seemlessly on most network configuration, bypasses most NATs and firewall without additional setup, etc).
Because of the community effort put into making rust work with godot, iroh is probably a better choice for pure server-less P2P (basically each client also is a server) but this kind of networking is not to be used everywhere. It can be really good at some things but transitioning from client-server to server-less really is a big paradigm change, especially in how you handle “truth”.
Basically, this kind of server-less P2P setup can be crazy good when you need “highly responsive small session multiplayer without that much entity to handle” (even better than server-client architecture since you might get a better latency by eliminating the server between two players) but it can quickly become a nightmare in the bad context.
I would say Bones’ style P2P is cool for:
fighting games (smash bros)
coop rogue-like/lite
couch-coop over internet
basically anything with small amount of player/entities, where responsiveness matters
but it’s probably much worse than a classic server-client architecture for:
MMOs
CS:GO-style multiplayer
Sandbox/Survivals
basically anything with persistent world, a lot of entities and/or lot of players
Something to take in consideration with this kind of networking also is the trust consensus (no server or host means no central authority) and the latency-compensation technique. For instance, Bones uses roleback, which is in part why it’s so good at the kind of contexts I said earlier because making as much stuff deterministic means you don’t need to wait every info from the other peer, you can “guess” most of the time by letting the deterministic code run. For example, in a smash bros inspired game, if playing agains a player with a lot of latency, you might see a big of latency when he jump, but you will never see him float in the air because the gravity is one of those deterministic systems you can compute locally without waiting for the other player’s information that says “btw, i’m falling down”.
With built-in godot netcode, you need one of the players to also be the host.
One way you can do that is like with minecraft. One player clicks “host server”, the game instance sends UDP packets to 192.168.0.255 (or whatever is the broadcast address of your local network) and any other computer looking for a server to join will wait for these broadcast UDP packets where you can provide just IP and port of the server or add more bells and whistles like session name, game mode, player count, etc.