Adding MULTIPLAYER NETWORKING with WebRTC to my game engine [Voxel Devlog #5]

Поделиться
HTML-код
  • Опубликовано: 16 июл 2024
  • During this video, I talk about the networking infrastructure I've created to facilitate seamless multiplayer in my voxel engine. I talk about my motivation for the design and why I chose a peer-to-peer model (although servers will still be supported). I then discuss the technology of WebRTC, the library that programs like Discord employ to help users' computers communicate directly. Finally, I display a proof-of-concept in which two clients concurrently modify a shared voxel world over a WebRTC connection.
    Music used in the video:
    Peyruis - Swing
    David Cutter Music - Over There
    AdhesiveWombat - 8 Bit Adventure
  • ИгрыИгры

Комментарии • 43

  • @netcore10
    @netcore10 2 года назад +25

    Honestly can't wait to play around. It was very smart to focus on multiplayer VERY early.

  • @henokabdo9663
    @henokabdo9663 Год назад +2

    Impressed by the length of your lines

  • @42222
    @42222 2 года назад +6

    I'm working on a similar passion project using three js and node js. At first I had the same idea of peer to peer connections. But then soon scrapped that idea altogether. The reason being the lack of a "single source of truth" within the network making hacking extremely easy. Thats why in my game only the direct keyboard and mouse inputs are sent to the server. The server calculates the new position and sends it back. This eliminates all hacking posibilities, except the ones done on the user input side, which is basically impossible to prevent. This is incredibly important for a production level game.

    • @42222
      @42222 2 года назад

      @@h..h you missed the point

    • @lucasbrunner6283
      @lucasbrunner6283 2 года назад +3

      It all depends on your use case. If it’s just you and your friends playing together casually then a server authorizing every movement isn’t necessary. Even if it’s an “official” server if the game is played in individual play sessions with no effect on one another then a cheat report system that integrates with matchmaking will do the job well enough.

    • @42222
      @42222 2 года назад

      @@lucasbrunner6283 Sure, but if you ever want to make a real game out of it you should think about these things from the start, because otherwise youll be rewriting everything because it cant be fixed otherwise.

    • @realdlps
      @realdlps Год назад +1

      What h h is recommending is client side prediction. The client gets to move around without waiting for the server but if the server decides that the client has moved to a place where they shouldn't be the server will correct the players location

    • @diadetediotedio6918
      @diadetediotedio6918 Год назад +1

      You can use a consensus algorithm to make hacking harder in P2P networks, as weel using a randomly elected peer to be the source of truth based on its storic on games (you can make your server as a elected peer for some weeks and then use clients to decide by themselves)

  • @true1158
    @true1158 2 года назад +5

    11 Minutes Of Glory

  • @Amp64
    @Amp64 2 года назад +4

    Really cool project! Can't wait to see where you go with this in the future!

  • @Mistereee
    @Mistereee 2 года назад +1

    This is looking like a very good game, I will definitely be playing the browser version when you release it

  • @Alexey_Pe
    @Alexey_Pe 2 года назад +1

    Man you are so cool. I agree that multiplayer is very important

  • @Console.Log01
    @Console.Log01 10 месяцев назад

    adhesivewombat in this video is crazy, most of his songs are really good. this project is also extremely cool

  • @grevel1376
    @grevel1376 2 года назад

    btw I love your videos and this project

  • @cmilkau
    @cmilkau Год назад +1

    Pulsar: Lost Colony is a very cooperative team-based PVE game. I think it's pretty unique.

  • @Conlexio
    @Conlexio Год назад +2

    you mention having the signaling server and the auth server be on the same process, i would suggest having these as microservices so they not tightly coupled. sometimes minecraft’s auth server goes down but you should still be able to create p2p instances
    you could even containerize the microservices and that opens up a lot of doors with hosting providers and process manangement

    • @DouglasDwyer
      @DouglasDwyer  Год назад

      This is a neat idea! I haven't done too much work with microservices, so I'd like to play with them in the future.
      Unfortunately, I'm not sure if your idea is applicable to my situation. My current intention is to allow users to connect via their accounts - so if Player A wants to join Player B's game, Player A requests to join the game hosted by Player B's account. This ensures that only users who own the game can connect, and that all users have a persistent and unique identity. Without an auth server up and running, I'm not sure how a signaling server would get account data.
      Perhaps one thing I could do (and what you are suggesting) is to separate the login server from the signaling server. So players can log in, and then generate an auth token, which is stored in a shared database between the login and signaling server. From there, the signaling server can use those tokens directly, even if the login server is down. I'm not sure whether the added complexity would be worth it, initially - I would have to see how it works at scale :)

    • @Conlexio
      @Conlexio Год назад +1

      @@DouglasDwyer yep! i was thinking potentially a login token too like a JWT. but if that’s not going to work i moreso just wanted to plant that idea in case something else could benefit from it! - (maybe if/when you add a player skins service like minecraft has, or a frontend website, or an update checker) :)
      thanks for the reply!

  • @Dannnneh
    @Dannnneh Год назад

    Very interesting!

  • @MESYETI
    @MESYETI 2 года назад +1

    very cool

  • @TreeAtmos.
    @TreeAtmos. 2 года назад +1

    ken silverman would be proud

  • @diadetediotedio6918
    @diadetediotedio6918 Год назад

    ABSOLUTE CHAD

  • @zulc22
    @zulc22 8 месяцев назад

    you're really fucking cool, btw

  • @anj000
    @anj000 9 месяцев назад

    I was kinda expecting a performance comparison between C++ and Rust, since you did something similar for C# and C++.

    • @DouglasDwyer
      @DouglasDwyer  9 месяцев назад +2

      In most of the engine code that I've tested, Rust and C++ perform comparably.

  • @bu3778
    @bu3778 Год назад

    shadows when?

  • @jawadch8723
    @jawadch8723 2 года назад

    First

  • @Kavukamari
    @Kavukamari Год назад

    is it going to have rollback netcode 🤔

  • @grevel1376
    @grevel1376 2 года назад +1

    what dependencies do you use?

    • @DouglasDwyer
      @DouglasDwyer  2 года назад +1

      I utilize glow for OpenGL and 3D rendering, with winit for windowing. I employ the wasm-bindgen ecosystem for WASM utilities, and the WebRTC code shown in this video is a custom library I wrote called "pinch" (it is based on libdatachannel). While there are a number of other smaller crates that I consume, I believe that covers all of the big ones. Everything else is written in-house!

    • @grevel1376
      @grevel1376 2 года назад

      @@DouglasDwyer great, looking forward for new videos!

  • @mcccxxxvii
    @mcccxxxvii 2 года назад

    Will you have a Discord server for the project?

    • @DouglasDwyer
      @DouglasDwyer  2 года назад

      Many people have asked about this! Right now, I am focused on growing my RUclips channel and continuing to build the core of the engine. However, since I enjoy talking with others about voxels, I will definitely consider making a server in the future :)

  • @nou5440
    @nou5440 2 года назад

    whats stopping cheaters from deleting the entire map or something

    • @DouglasDwyer
      @DouglasDwyer  2 года назад

      Nothing at the moment - but I will implement such measures in time. The game is still host-authoritative in matters like voxel editing, so once all the game logic is implemented, players will only be able to place and destroy the structures that they're allowed to. This is the same as in Minecraft; it's impossible for a hacker to (naively) destroy an entire chunk of blocks, because the server simply says "no." In this case, if a player hosts a game, only their copy of the game will have control of the world. If a server hosts a game, then only the server will have the authority.

  • @anzhel3268
    @anzhel3268 2 года назад +2

    Bruh, you should have stuck to Client-Server and maybe used a more professional language.

    • @DouglasDwyer
      @DouglasDwyer  2 года назад +2

      Client-server is still possible; the server just acts as one of the peers :)
      As for more a more professional language, you mean, like C++? Well I suppose I cou--- SEGMENTATION FAULT (CORE DUMPED)

    • @anzhel3268
      @anzhel3268 2 года назад +1

      @@DouglasDwyer P2P always seems to have implementation problems and ends up unreliable in released applications, it also gets increasingly bad with player count which is huge for me even for 3-4 players.
      The "safety" of rust is overrated and even big supporters of it subconsciously avoid it. This talk/rant is good if you are interested ruclips.net/video/4t1K66dMhWk/видео.html

    • @DouglasDwyer
      @DouglasDwyer  2 года назад +3

      Could you elaborate on your statement about player count? To clarify my networking architecture, the typical set up will either be clients connect to a server (using WebRTC technology), or clients joining each others' private games by all connecting to the player hosting the game. So the standard client-server architecture is completely possible. I can definitely see latency being an issue for player-player connections if lots of people join the same game, because client bandwidth is relatively limited, but at that point the clients CAN still connect to a server. So unless there's a problem with WebRTC and a large number of concurrent connections in a server-client model, I believe this is a non-issue.
      As for Rust, I choose it not just for the safety but also for the more modern idioms (like proper generics and lexical macros) and the expansive, WASM-supporting ecosystem. I've worked in both Rust and C++, and between the two, I personally prefer Rust. I mean, it's 2022, and we still have to write header files? Really? It's certainly a personal preference, and there's nothing wrong with writing an application in C++. But there's also nothing wrong or bad about writing in application in Rust. In fact, I find that it much better supports my development goals :)
      Last, I just want to thank you for taking the time to share your personal view. I do enjoy hearing from other people with different perspectives - if I get an opportunity, I will watch the talk you cited!

    • @anzhel3268
      @anzhel3268 2 года назад +4

      ​@@DouglasDwyer By the player count part I meant that for pure P2P players already connected to the same game and in close proximity send messages directly as it can reduce latency by not having to go to the server. From the video I could not understand your networking model in detail so I thought you simply left out the details. Your clarification looks exactly like a Client-Server model as it keeps the server in complete authority and I see no problem with that, that is how I would have done it. P2P is not widely supported on the web as it is complicated and it doesn't care about latency as we can see from how bloated it is. By letting players host their own games and publicize their IP it can lead to their connection getting cheaply attacked as most PCs and home routers aren't protected. It's very tempting to do use P2P as it can save bandwidth and computing power but for smaller projects I don't think it's best. Maybe still letting players run the game logic but routing the traffic through a server of your own is good but I have never tried.
      I do not see any benefit in Rust as you can still compile C/C++ to WASM and run it smoothly. Although they are dated and header files are ancient. C is by far the most reliable, secure and widespread language. There are reasons why every language since it has been trying to recreate it, it had very good ideas at it's time. Knowing everything that happens in your code can help you tons with fixing problems and that is something that Rust does not make easy.
      Your project looks like a serious and passion-driven and I hope to see it succeed when it's released!

    • @diadetediotedio6918
      @diadetediotedio6918 Год назад +2

      "Professional language" is the one that does the job, regardless of whether it's Rust, C#, C, C++ or even Java. Trying to correct someone because of the language that person is using is quite amateurish behavior, the right question should be if this language is the tool that is solving the problems that he wants to solve in the best possible way for the context and resources he has.