Using WebRTC in Unity with STUN server DataChannel over WEB!

Поделиться
HTML-код
  • Опубликовано: 18 сен 2024

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

  • @EAREC_SAWAN_KUMAR_CHOUHAN
    @EAREC_SAWAN_KUMAR_CHOUHAN 4 месяца назад

    Thank you for uploading this❤

  • @Doing01
    @Doing01 3 месяца назад

    Hi! Thank you very much for your work! I learn a lot in the few days, when i finded your channel.
    Is there any future plan to creat a video vith this STUN server, and sending multimedia like the 3. Video in this Web RTC searies?

    • @firedragongamestudio
      @firedragongamestudio  3 месяца назад +1

      It's actually in the making. Hope to release it within the next 2 weeks :)

  • @creggy
    @creggy 3 месяца назад

    Thanks for a good series. Just curious, have you used the unity render streaming library at all? You mentioned it in the first video but unless im mistaken as Ive only skimmed through them and not done them alongside you, that you dont use it for the audio and video streaming, is that correct?

    • @firedragongamestudio
      @firedragongamestudio  3 месяца назад +1

      Hi, ah sorry after watching the intro again, it's so obviously confusing. I don't use the render streaming at all. Everything is self written and this video is actually part of a series, where I use and extend the code from my previous videos. I wanted to show the usage of WebRTC in Unity without using the provided render streaming library. Best thing to start, would be to look at the first WebRTC videos I posted a while ago and follow them. I'm explaining the source code in great detail there too, so it's quite easy to implement everything from scratch :)

  • @sissoko11
    @sissoko11 4 месяца назад

    Hi there, is the source code included in your T3 membership also useful for creating mutliplayer WebGL games in Unity? Or is it mostly just geared towards streaming audio/video?

    • @firedragongamestudio
      @firedragongamestudio  4 месяца назад

      WebGL is not supported by Unity WebRTC (checked the docs) and yes, this sound's ridiculous but is unfortunately true :( You can use the websocket implementation nevertheless for sending data between connected clients. You can use libraries like websocket-sharp or NativeWebsocket for that. Unity's transport package also supports WebSockets starting with its 2.0.1 version (only available on 2022.2 and later).

    • @sissoko11
      @sissoko11 4 месяца назад

      @@firedragongamestudio There is a video here of someone using WebRTC in a WebGL build: ruclips.net/video/be9VtUymNPs/видео.html

    • @sissoko11
      @sissoko11 4 месяца назад

      @@firedragongamestudio This seems like a big untapped niche to me, multiplayer games in browsers are laggy due to depending on TCP but they are the most accessible games and often the easiest to play with friends, seems to me we should really have WebRTC working well for WebGL builds

    • @firedragongamestudio
      @firedragongamestudio  4 месяца назад

      @@sissoko11 you're right here! But WebRTC is not the ultimate solution for having data sent over the web, as you'd need a signaling server. WebSocket does exactly what you want, but you'll have to do a little more work yourself.

  • @user-wf4nr4mp1v
    @user-wf4nr4mp1v 3 месяца назад

    I ran the server code exactly in the glitch IDE, but nothing happens.
    Can you explain in detail how to open a server and integrate it with Unity?
    I also installed ws through adding packages in glitch IDE, but I don't know how to use it.

    • @firedragongamestudio
      @firedragongamestudio  3 месяца назад

      It depends, you can integrate everything in Unity, but the Web option will then have to be configured all by yourself, like hosting etc. Have you tried if the signaling is working?

    • @firedragongamestudio
      @firedragongamestudio  3 месяца назад

      You can either create the webserver within Unity (as in the LAN samples), a local webserver (e.g. with npm, bun, vite, etc...) or the online solution with glitch.

    • @user-wf4nr4mp1v
      @user-wf4nr4mp1v 2 месяца назад

      @@firedragongamestudio I am studying how to create a server through sockets in C#. thanks

    • @firedragongamestudio
      @firedragongamestudio  2 месяца назад

      @@user-wf4nr4mp1v Check the videos and samples for WebRTC over LAN. The websocket server is created in Unity with Websocketsharp :)

  • @dhiasendi8498
    @dhiasendi8498 Месяц назад

    Hi, Thank you very much for your work.
    I'm having some issues getting it works when two Instances are on different networks (having the same one works fine though)
    For example with this particular example, when clicking on the first button "WebSocket Test Msg" I got this:
    WebRTC-DataChannel-STUN - Received: TEST!WEBSOCKET TEST
    However, when clicking on the second button "WebRTC Data Test Msg":
    InvalidOperationException: DataChannel is not open
    Also, "OnIceConnectionChange" state's when on 2 different networks is always "Failed"
    Any suggestion would be very helpful

    • @firedragongamestudio
      @firedragongamestudio  Месяц назад

      @@dhiasendi8498 Sometimes the router itself blocks WebRTC connections. Had an issue with a few Fritzboxes in the past. Do you get the ICE message of both clients that a successful connection was established? Have you tried the source code from my example? There is a chance with custom client code, that an ICE state is missing.

    • @dhiasendi8498
      @dhiasendi8498 Месяц назад

      @@firedragongamestudio Thank you for the fast reply!
      You are right about the ICE CONNECTION STATE, when on two different networks it always "Failed"
      And yes I made the test with source code from your example, after getting this issue on mine

    • @firedragongamestudio
      @firedragongamestudio  Месяц назад

      @@dhiasendi8498 hmmm... Do the ICE messages get sent via websocket server? The logs should show quite an amount of ICE messages. Try to start the Windows client first, the Android client a few seconds later. Does that help?

    • @dhiasendi8498
      @dhiasendi8498 Месяц назад

      @@firedragongamestudio I just tried with two different Android instances each one with different Network and I can confirm it's working fine!
      So I think the issue is within my Router, Pc or both (having high restrictions).
      One final question, regarding some latency, does changing to another server (I'm currently using Glitch free plan) or upgrading the plan could make it better?

    • @firedragongamestudio
      @firedragongamestudio  Месяц назад

      @@dhiasendi8498 Thank you for the feedback :) Maybe a TURN server could work around your connection issues, with tight security. The free Glitch plan is not the fastest and you can't choose where the websocket server is hosted, so there is a high chance of noticeable latency. Not sure if the paid plan will do better, but maybe you can create/rent a websocket server at a "local" hosting provider or even host it yourself. This should indeed improve the streaming.

  • @user-wf4nr4mp1v
    @user-wf4nr4mp1v 3 месяца назад

    Where can I see the tutorial code?

    • @firedragongamestudio
      @firedragongamestudio  3 месяца назад +1

      Thank you for joining the channel ♥️ Send me your GitHub username in the community tab (first post for members) and I'll add you to the repository 😃