Godot Peer-to-Peer over the Internet (The easy way)

Поділитися
Вставка
  • Опубліковано 28 вер 2024

КОМЕНТАРІ • 88

  • @simplexeon
    @simplexeon 10 місяців тому +20

    I have literally never seen this anywhere else and I don't know why because you explain it so simply. I have seen a lot of multiplayer tutorials and all of them say something like, "To use multiplayer over the network, you'll need to use a dedicated server so we won't get into that." Now, for this, you would still need a server to connect the clients to the hosts, but this is so much easier than any of the other stuff.
    Thanks for the help!

    • @sexcar4741
      @sexcar4741 2 місяці тому

      the server controls everything

  • @bomb_jaguar
    @bomb_jaguar Рік тому +10

    I saw this video multiple times and still could not fully understand it, but when I tried in a test project, its LITERALLY just copying the code and using ENetMultiplayer, thanks a lot!

  • @netanelkomm5636
    @netanelkomm5636 Рік тому +15

    Is there really no other way? Because for me I had to enable UPNP on my router. I really dont think the end users should be messing with their router just to play a game.

    • @TheDarkfire9251
      @TheDarkfire9251 8 місяців тому +4

      UPNP isn't always enabled because it's a considerable source of cybersecurity issues. You can't really have a hands-off multiplayer experience that will work in every configuration without external servers, which is why most developers use them.

  • @_gamma.
    @_gamma. 2 роки тому +9

    WOW that’s simple, thanks for sharing!

  • @tunaep_yt
    @tunaep_yt 4 місяці тому +1

    I have followed your tutorial and then I implemented it into your earlier tutorial with the balls moving around, but now my players aren't spawning :( I don't know what I have done wrong

  • @tig5ran575
    @tig5ran575 Рік тому +6

    Hello DitzyNinja! I already saw in a couple of comments that reported the problem of a non-working Discovere, but no one gave a detailed answer to this question. I also ran into this problem and would really appreciate it if you could help!

  • @mrjshzk
    @mrjshzk 4 місяці тому

    This is soo helpful, I'll try using it to see if it works!

  • @ibluebee2832
    @ibluebee2832 5 місяців тому

    Actually, a lot of routers don't have UPNP enabled from the start. sunrise router for example. So thanks, but i can't do this for my game since i don't have UPNP enabled on my router :(((

  • @darc9925
    @darc9925 Рік тому +3

    After a few hours of trying to turn on Upnp on a starlink router. It turns out that uncle Musk decided that it is too unsafe and is not even a router option.

  • @KaletheQuick
    @KaletheQuick 8 місяців тому

    This is really amazing!
    Would anyone know a quick way to scan ports and make sure I get one that's free? I'd prefer to look in a little range or something rather than guessing that nothing has taken my magic number.

  • @rueful13
    @rueful13 Рік тому

    Are there any godot 4 updates?

  • @BHanif-zc2pr
    @BHanif-zc2pr 2 роки тому

    Can 4 different people from 4 different network connect by this way? Can i use a number as a port whatever i want?

    • @ditzyninja
      @ditzyninja  2 роки тому

      Yeah. I have other videos with more information on actually connecting clients to a server. You can use any port number from 1024 to 65535. And the limit for number of people that can connect is 1024 I believe.
      Here are those other videos:
      ua-cam.com/video/ZF2E12apggU/v-deo.html

    • @BHanif-zc2pr
      @BHanif-zc2pr 2 роки тому

      @@ditzyninja Then sir.. i want to make a multiplayer game and publish it on play store.. suppose you download my app then create a server on my app. And ask your friends to join the server who are in japan, chaina, uk.
      My question is how can i make my user able to create their own server and connect their friends on that server..

    • @BHanif-zc2pr
      @BHanif-zc2pr 2 роки тому

      @@ditzyninja is this upnp works with only on router? then how can i do it for those who will play the game by sim data ..

  • @lukagarner
    @lukagarner Рік тому

    Could I just use TCP tunneling? An external service like ngrok

    • @espvolt4833
      @espvolt4833 6 місяців тому

      yes but doesnt work with udp

  • @himihub
    @himihub 2 роки тому

    Does this works with the Android?

  • @TommyLikeTom
    @TommyLikeTom 10 місяців тому

    Good job reproducing the UPNP documentation but there is no proof that you actually got this to work

  • @YCCCm7
    @YCCCm7 7 місяців тому +8

    How the hell did it take me 20 google searches to get here? This is like the easiest method vs all the other shit that crops up. Thanks a brazillion.

  • @pjburnhill
    @pjburnhill Рік тому +11

    Excellent stuff, and easy to set up! Would love to see more content on optimization and maybe WebRTC or even ENet mesh networking! Thanks!

    • @ditzyninja
      @ditzyninja  Рік тому +2

      Thank you! I've played around with that stuff. I'm very far off from understanding it to the point that I could teach someone else though unfortunately. Maybe one day lol

  • @robotamori
    @robotamori Рік тому +5

    Getting invalid gateway error while trying to get_gateway() :(

  • @Gyozamang
    @Gyozamang 11 місяців тому +6

    would you consider making a very simple "game" (like moving a player left/right and maybe instantiating a bullet) using this networking method to give example on how you'd implement this? It would help my understanding seeing a practical example , thanks for the vid either way

  • @sidi8985
    @sidi8985 2 роки тому +9

    While UPnP is great i fear that with the increasing number of ISPs implementing CGNATs its becoming even harder to open ports on ipv4 based networks, right now imo the best option is to also implement a nat punchthrough as a fallback in case Upnp fails to work

    • @ditzyninja
      @ditzyninja  2 роки тому +5

      I just looked into CGNATs, it sounds like you're right

    • @-Name-here-
      @-Name-here- Рік тому

      I've looked into it a bit, and from what it looks like it seems that cgnats break alot more than just games. I think I'll just give an error saying cgnats aren't supported, and let them connect to a friend instead.

    • @pepe-gamer
      @pepe-gamer 10 місяців тому

      CGNATs are now the standard in high population areas in my country :(

    • @FOTPFan
      @FOTPFan 4 місяці тому

      ​@@ditzyninja Having looked up what the hell a CGNAT is and why it's causing more problems in this type of communication rather than regular ISP issues... I found a neat thing called PWNAT that might help as a sidecar program outside of Godot. Unsure at this point though. It mentions "server" and "client" but what I am seeing hints that any computer/player could be that "server," like the old days of gaming where we had to call up our friend and ask their IP or literally dial their computer/home phone number. (before self-hosted games that used a thirdparty negotiation server like the original Halo for PC but were hosted by whoever opened the lobby.) I'll probably have to learn a lot more about it especially for a major project I have going in another country with SAR, medical and other important applications that shouldn't stop working just because an ISP got cheap... I'll update if I learn more about how to use it and put it into Godot or around Godot games/applications

  • @fluffypancakes1281
    @fluffypancakes1281 2 роки тому +9

    Could you either explain or make another video on how to expand this video's content so that you can connect to the server?

    • @ditzyninja
      @ditzyninja  2 роки тому +5

      On the server side: after forwarding port 9999 (Or whatever port you used) you create the server using that port.
      On the client side: you create the client using that port and the IP returned by query_external_address().

    • @ArabGameDev
      @ArabGameDev Рік тому

      yes i agree
      i need more info

    • @fluffypancakes1281
      @fluffypancakes1281 Рік тому +1

      @@ditzyninja could you maybe create another, as i think it could be really useful to myself and other people trying to create a server on a client.

    • @ditzyninja
      @ditzyninja  Рік тому

      @@fluffypancakes1281 I'm going away next week, but I could create another video expanding on this a bit when I get back

    • @fluffypancakes1281
      @fluffypancakes1281 Рік тому

      @@ditzyninja That would be amazing, I have been trying to figure out how

  • @mouseroot8053
    @mouseroot8053 2 дні тому

    the query_external_address part is kinda a golden egg, usually i have to use an http request to an ip service, this was nice to have as another way to get the external ip, once again godot makes things so simple.

  • @lucasfranca4543
    @lucasfranca4543 Рік тому +3

    I made a chat system and it Works like a charm!... Thank you!

  • @RealPnoenix
    @RealPnoenix Рік тому +3

    Thank you so much, this fixed all my problems!

  • @m0-m0597
    @m0-m0597 9 місяців тому +1

    You talk a bit fast but dang you saved my butt with this video.

  • @JoseRoberto-wt8vz
    @JoseRoberto-wt8vz 10 місяців тому +1

    Awesome, congratulations for your didatic

  • @isomerism1853
    @isomerism1853 2 роки тому +3

    That's so cool

  • @bennettmiller3586
    @bennettmiller3586 Рік тому +2

    Wow, this works, thank you so much for making this video!

  • @Thomason1005
    @Thomason1005 4 місяці тому

    this. was troubleshooting for 3 days, opening ports, ipv4, ipv6, but this made it work. at least in one of 2 networks it did. only change i made is to run it in a thread, so the game doesnt freeze for 2 seconds.

  • @JoshuaSaffy
    @JoshuaSaffy 4 місяці тому

    How'd you know I had this exact problem XD Thanks. I appreciate that you don't just I assume I know everything and just say port forwarding and instead explain that and then show an example, all in like 3 miniutes

  • @benzenatizineeddine7816
    @benzenatizineeddine7816 6 місяців тому

    that's a very useful feature since it can prevent unnecessary extra charge especially when using relay servers that help against asymertric NAT.
    But that doesn't save us from the need to use a signaling server so the peers can connect with each others.
    the P2P is the best ally of the poor indie developers wanting to do a multiplayer, i thought about using nakama with kubernetes but stopped living in denial i just know i don't have what it takes to secure the cluster so .... thanks for sharing this feature

  • @touqui8659
    @touqui8659 9 місяців тому

    It work for my tower (internet) but not for my laptop (wifi)

  • @cjdaylight3407
    @cjdaylight3407 Рік тому

    I can port forward my rotuer some reason connection ip router port server port are same but it is not worked on me

  • @shindig9000
    @shindig9000 Рік тому +1

    I have a question.
    Is there a way to mask the external IP address to something else for people to type in to connect instead of someone wanting to join needing this external address?
    I was thinking it might make it slightly safer and easier for people to type in instead of the IP.

    • @funy0n583
      @funy0n583 Рік тому

      not without some form of a proxy, otherwise the host ip would eventually end up on the players computers regardless of whether its immediately visible to them. If you don't mind the host ip being shared you could make a server that holds all hosts ips and assigns a smaller, easier to understand, id to them that the players can use rather than the full ip, this way wouldn't be much safer but it would be more convenient.

    • @-Name-here-
      @-Name-here- Рік тому

      my idea is to get some sort of free encryption system on godot, and set the key to be a number randomly generated by godot after seeding godots randomization with the current day/month/year.

    • @shindig9000
      @shindig9000 Рік тому +1

      @@-Name-here- but if you are hosting, doesn't the connection still get sent straight to you external IP?

    • @-Name-here-
      @-Name-here- Рік тому +1

      @@shindig9000 well, you’d type in an encrypted code, and godot would turn it into an unencrypted ip address, and connect to that.

    • @-Name-here-
      @-Name-here- Рік тому +2

      @@shindig9000 it would appear I misunderstood this. Yes, people would be directly connecting to you, and that is a security risk. I’m personally going to look into finding a way to use epic online services in godot, but this is a nice backup I suppose.

  • @rifqinugraha742
    @rifqinugraha742 2 роки тому +1

    thank you help me

  • @voidbyteyt
    @voidbyteyt Рік тому

    i don't have a UPNP option

  • @bonsaipropaganda
    @bonsaipropaganda 7 місяців тому

    this is what im gonna use thanks a a bunch!

  • @Chris-Brown-
    @Chris-Brown- Рік тому +1

    this is UPNP not peer-to-peer, e.g. create_mesh

    • @ArabGameDev
      @ArabGameDev Рік тому +2

      UPNP does create port forwarding which is p2p

  • @IamWibbly
    @IamWibbly 2 роки тому +1

    get_getway() returns [Object:null] for me. Any idea what the problem could be?

    • @ditzyninja
      @ditzyninja  2 роки тому

      For some reason the discover() method isn't finding router. I'd check your router settings to make sure it has UPnP enabled.
      What model of router do you have?

    • @IamWibbly
      @IamWibbly 2 роки тому

      @@ditzyninja I made sure its enabled: i.imgur.com/nq6pf5f.png
      Also enabled the service which I found out was Manual by default: i.imgur.com/vqs6yn0.png

    • @ditzyninja
      @ditzyninja  2 роки тому

      @@IamWibbly If you have an extended security options, see if turning that off helps.
      What do you get when calling get_device_count() on the upnp object?

    • @IamWibbly
      @IamWibbly 2 роки тому

      @@ditzyninja I found 2 firewall protection options and turned them off: i.imgur.com/g7nVuTA.png
      But still have the same problem, here's what I'm getting from UPNP: i.imgur.com/vZ5jwzO.png

    • @ditzyninja
      @ditzyninja  2 роки тому

      ​@@IamWibbly Hmm It looks like your upnp object has found router. You could try skipping the get_gateway() step and just go directly to add_port_mapping(). Do you have a second computer that you could test the port forwarding with?
      Oh and just a heads up, the discover_result is an error code (0 means everything's OK), I noticed you were using it as the index in get_device()

  • @manuelnaim9206
    @manuelnaim9206 2 роки тому +1

    get_getway() returns [Object:null] for me too.

    • @manuelnaim9206
      @manuelnaim9206 2 роки тому

      If I check I get IGD_STATUS_DISCONNECTED

    • @Jarason429
      @Jarason429 Рік тому

      Did you find a fix?
      @@manuelnaim9206

  • @anarcus
    @anarcus Рік тому +1

    get_geteway() returns [Object:null] for me, even though discover_result == UPNP.UPNP_RESULT_SUCCESS