5 ms·
Making peer-to-peer multiplayer seamless with Godot (2022)
- Laremere 3y ago> If you’re looking for a way to have peer-to-peer multiplayer without setting up your own server, have a look at Steam’s Networking API which also has a Godot integration via GodotSteam, or have a look at the Epic’s NAT P2P API. Both provide NAT hole punching support with relay services as a fallback. Steam used to work this way iirc, but they now always use a relay. This is user friendly, because with normal peer to peer your IP address is given to other players. DDOSing, bringing down Twitch streams, and all sorts of unfun things can result from that. Of course, this does give steam your users' IP addresses.
- zamalek 3y ago> Of course, this does give steam your users' IP addresses. A rendezvous is unavoidable, even for UDP P2P. The hole puncher server would be the rendezvous -- or the STUN (P2P) / TURN (TCP) server if you wanted to make the smarter choice and use an existing protocol. Either way, the rendezvous gets the IP no matter what. The only way to avoid leaking the IP to some middle party is to use port forwarding and manual communication of the IP.
- TechBro8615 3y agoIIRC, Twilio offers a paid STUN/TURN service. But you could also self-host it using some open source TURN server, since all it requires is a public IP address (with the caveat of course that it might not be geographically close to the end user).
- imtringued 3y ago>The only way to avoid leaking the IP to some middle party is to use port forwarding and manual communication of the IP. You're responding to someone who is concerned that the enemy player is going to cheat and your suggestion is to straight up tell him what to DoS?
- zamalek 3y agoI'm responding to the bit about steam.
- fidotron 3y agoWorking in games is an amazing way to discover abusive behaviour and the value of defensive programming, and that is just for dealing with your colleagues (may not be joking). Gamers are incredible at breaking things when using your product legitimately, once they decide to look behind the curtain you are in trouble. One of the big advantages (acknowledging the downsides) of in cloud gaming is it dramatically reduces the scope for this.
- jasonjmcghee 3y ago(2022) - specifically January. This is particularly relevant as Godot 4 released in March 2023, and multiplayer was overhauled.
- turpialito 3y agoWait, Didn't Quake and Unreal used to network by self-hosting?
- dustfinger 3y agoBack in the days of Duke Nukem, Quake and Unreal, we connected with no NAT using 1400 baud modems, if we were lucky ;-). Honestly though, I played direct (peer 2 peer) with Duke Nukem and conected over a centralized server for Unreal, but I hardly ever played Quake. I did this, with a 1400 baud modem and a phone-line that I paid for myself, with the earnings I made from a paper route job. It was the 90s and it was something special, for me at least.
- loloquwowndueo 3y ago1400? I doubt it. 14400 maybe.
- deleted 3y ago[deleted]
- zer0-c00l 3y agoyou mean 14.4k - 1400 baud was outdated far before that
- dustfinger 3y agoYah, I was wrong on the speed.14.4k sounds right. I believe I started on a 9600 baud, then 14.4k.
- totetsu 3y agoWe preshared phone numbers
- abwizz 3y agomost games back in the day had to have a self-host option for lan gaming w/o internet access. this usually also works with global ip addresses
- jesprenj 3y agoSo they don't need a server, but they need a server at the same time (: One could abuse BitTorrent's existing DHT infrastructure (:
- imtringued 3y agoWhat we need is widespread IPv6 support. Portforwarding isn't the problem. The terrible UX and the existence of CGNAT (carrier grade NAT) is.
- Zetaphor 3y agoAs someone who only understands the benefit of IPv6 to be the much larger address pool, can you elaborate on how it would make this situation simpler?
- chainingsolid 3y agohttps://tailscale.com/blog/how-nat-traversal-works/ https://tailscale.com/blog/how-nat-traversal-works/ This was posted to HN recently and has the answer you asked for better written up the I can write here.
- amarshall 3y agoThe problem is NAT as it makes it impossible to directly address, and NAT doesn’t exist in IPv6 (because NAT is primarily needed to workaround limited public addresses).
- grumpy_coder 3y agoIPv6 support is pretty 'widespread' at this point. >50% last I did a quick test You unfortunately need ubiquitus IPv6 support to actually rely on IPv6, which isn't going to happen anytime soon. So you really need to consider the benefits of dual stack v4 and v6 simultaneously within the same group of players. Might be useful, but it adds a whole heap of complexity.
- p1mrx 3y agoCGNAT is not a problem. It is a necessity because there are more humans than IPv4 addresses. The problem is deploying CGNAT without also providing IPv6 as an alternative.
- jscottmiller 3y agoI’m not familiar with Godot networking primitives in 3.X, but 4.0 contains WebRTC support which, combined with a STUN/TURN server, solves the hole-punching problem. You need to run a signaling backend to pass connection info between the peers, but you’ll probably want to build a messaging service anyway for matchmaking.
- ktbwrestler 3y agoThis is awesome! As someone new to Godot that wants to learn how to build multiplayer asteroids, should I try to build something standalone or browser based? Do you recommend any tutorials to get started?
- arun-mani-j 3y agoAs another beginner, you need not worry much about the platform unless you have a very tight platform integration. Which means, as long as your code dependent fully on Godot, everything works fine. So there is no difference. For the tutorial, once you read the basic syntax of GDScript, you can directly start coding a game of your choice and reading the docs on need. Or use the official 2D and 3D tutorial. (This is how I learnt, YMMV)
- nightowl_games 3y agoPro multiplayer Godot dev here. Account system and matchmaker: https://github.com/heroiclabs/nakama-godot https://github.com/heroiclabs/nakama-godot Top tier tutorials on multiplayer: https://gafferongames.com/post/what_every_programmer_needs_to_know_about_game_networking/ https://gafferongames.com/post/what_every_programmer_needs_t... Godot 3's browser support is currently better than Godot 4's (it was when I tested anyways, this changes every day and I don't use Godot 4). Making multiplayer work really well usually requires a dedicated server and client side prediction. There's a lot of complexity to making that happen however. You can use nakamas' messaging system as a transport layer for a game hosted on a user's device. Or you can use nakamas' match API to host the game in nakama, but then the game logic needs to be written for nakama in go, js, or Lua, which you can't then run locally in Godot.
- grumpy_coder 3y agoThe cost of servers these days, you really shouldn't be playing with NAT hole punching except for your own interest/fun. The number of simultaneous players on your little indie game are just not going to cause one medium sized server to break a sweat.
- IggleSniggle 3y agoA game requiring infrastructure means that the game requires someone to support the infrastructure, even if it's simple. For small projects or free games, your game can continue to have life if it doesn't require anything but the software to play it. And a $30/mo server cost is not cheap for a game that provides zero revenue (or even upfront-only revenue for a small indie game). I'm always super happy to see when a game supports zero-internet LAN play. That means I'm still going to be able to play it in 15 years if I want.
- deleted 3y ago[deleted]