Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Unity Multiplayer RakNet Networking Solution

Discussion in 'Connected Games' started by VictorZed, Jun 25, 2019.

?

Did you like the demo?

  1. Yes

    12 vote(s)
    100.0%
  2. No

    0 vote(s)
    0.0%
Multiple votes are allowed.
  1. VictorZed

    VictorZed

    Joined:
    Dec 24, 2015
    Posts:
    22
    Hello! When developing my game, I was faced with the fact that the Unity engine does not have a stable network (removed uNet), and I had to make my network solution based on the RakNet cross-platform network engine ...
    The engine itself is quite simple to use, there are no unnecessary functions ... In fact, what does a developer need? Just send and receive a packet from the client to the server or vice versa ... In general, I prepared a demonstration of my game, in which I applied this network engine and put the client and server in one application ...



    What has a demo?
    - ConVars (client & server side)
    - Debug Console (Key - F11)
    - Network Info (Key - F5)
    - Chat Commands (/help - for show all available commands)
    - Dedicated server console (for run use -batchmode argument)
    - Client Prediction & Server Reconcilliation (Lag compensation)
    - Low traffic consumption















    Demo Download link: https://drive.google.com/open?id=1yoowdbUcaKexBW8XfB7jkEQmlkV_VTBn


    See Github: https://github.com/ep1s0de3/RakNet_Networking

    WARNING! When importing RakNet.dll in your project toggle checkbox on x86_64
     
    Last edited: Jul 15, 2019
    akuno and TiToMoskito like this.
  2. VictorZed

    VictorZed

    Joined:
    Dec 24, 2015
    Posts:
    22
    Wow! Watch video :)
     
  3. Dareheim

    Dareheim

    Joined:
    Oct 12, 2013
    Posts:
    7
    So what? Let's source:D
     
  4. VictorZed

    VictorZed

    Joined:
    Dec 24, 2015
    Posts:
    22
    I am still adding code to make it convenient and understandable to use in your projects ... I will post it when end writting:) (in a couple of days)
     
  5. VictorZed

    VictorZed

    Joined:
    Dec 24, 2015
    Posts:
    22
  6. TiToMoskito

    TiToMoskito

    Joined:
    Jan 28, 2014
    Posts:
    34
    Thank you very much, would you share the server console part?
     
  7. VictorZed

    VictorZed

    Joined:
    Dec 24, 2015
    Posts:
    22

    I am still writing my project, when I finish with it I will lay out the source code on github
     
  8. F-R-O-S-T-Y

    F-R-O-S-T-Y

    Joined:
    Mar 22, 2013
    Posts:
    236
    Nice job. I wonder why was RakNet deprecated.
     
    VictorZed and akuno like this.
  9. OndrejP

    OndrejP

    Joined:
    Jul 19, 2017
    Posts:
    47
    I wish Unity stopped "experimenting" with their networking tech and properly integrated latest RakNet as "basic" networking level. Then build the rest (HLAPI) on top of that.

    RakNet is high-performance, stable networking library, which powers a lot of games. It's reliable and proven by time. I consider it industry standard.

    I don't like current "void", UNet is depracated, LLAPI will be depracated and current state of new tech is unusable (e.g. more than 32 packets waiting = silent dropping them - new Unity Transport). Couldn't they keep HLAPI and LLAPI little longer, fixing bugs until new tech is ready?

    We have successful product on Steam Early Access and currently facing decision what tech to use to implement multiplayer (we postponed the decision as long as we could). I've tested UNet few years ago and wasn't happy with it. We want something which can be deployed on demand by us and by community (dedicated servers) - no hosted solution. Also we're likely to write our own high-level tech on top of whatever we end up using.

    I'm slowly starting to think that best solution for us will be what author of this topic did (with Linux / Mac support)

    EDIT: There's one interesting thing, Valve open-sourced their API and networking library they are using for DOTA and CS:GO. It's part of SteamSDK, which we already integrated (but can be also used without it and works well with dedicated servers). The bonus feature is that non-steam version (GOG, Discord store, other platforms) of your game can use it and connect to Steam version of your game.

    More info:
    https://partner.steamgames.com/doc/api/ISteamNetworkingSockets
     
    Last edited: Jul 8, 2019
    VictorZed likes this.
  10. VictorZed

    VictorZed

    Joined:
    Dec 24, 2015
    Posts:
    22
    because the developers of the engine supposedly made a new network called uNet in 2014 or 2015, and deleted RakNet which was part of Unity3D ... And now there is nothing at all, neither RakNet nor uNet ...
     
  11. VictorZed

    VictorZed

    Joined:
    Dec 24, 2015
    Posts:
    22
  12. Aiursrage2k

    Aiursrage2k

    Joined:
    Nov 1, 2009
    Posts:
    4,817
    Hey guys im trying to send an image from the server back to the client but it wont be received if its above some certain threshold, i tried increase the maxbandwitth but im never actually to receive these packets on the client


    Okay never-mind I was sending it wrong. Thats what we need a low level library that we can actually use to do various things, I spent a few days trying to get photon to send/receive images from and to the server for the purpose of "streaming content" and couldnt do it because its too overegineered for 1 thing

    Okay I was having some problems getting to run as an exe but fixed the problem by looking at the logs and determing you had to select x86_64
     
    Last edited: Jul 12, 2019
  13. VictorZed

    VictorZed

    Joined:
    Dec 24, 2015
    Posts:
    22
    So large arrays of bytes need to be sent not entirely but in parts, otherwise the network stream will be suspended until the whole array is transferred ... And by the way, it is recommended to send such arrays not over one channel but over several ...
     
  14. VictorZed

    VictorZed

    Joined:
    Dec 24, 2015
    Posts:
    22
    Watch my new videos... :);)










    I rewrote most of the network code and now there are fewer lags. everything is done not in a while loop but in the FixedUpdate method



    As you may have noticed, I create false delays and network packet loss ... The Clumsy 0.2 program helped me in this.
     
    Dareheim likes this.
  15. Aiursrage2k

    Aiursrage2k

    Joined:
    Nov 1, 2009
    Posts:
    4,817
    I came up with a better method, instead of sending back images which was nonsense instead im going to actually stream video -- which might be better
     
  16. Litwin

    Litwin

    Joined:
    Aug 15, 2013
    Posts:
    60
    Amazing!! :p

    Are you using SLikeNet or original RakNet from github of the Oculos VR? You plan to release in github with features interpolation, predictions and etc?

    Thanks.
     
    Last edited: Jul 21, 2019
    VictorZed likes this.
  17. VictorZed

    VictorZed

    Joined:
    Dec 24, 2015
    Posts:
    22

    I use the original RakNet

    In the near future I will lay out the entire source code of the project on the github ... I can not say the exact date
     
    Litwin likes this.
  18. Litwin

    Litwin

    Joined:
    Aug 15, 2013
    Posts:
    60
    Oh great, I'm glad to hear that. Have you had any further progress?
     
  19. VictorZed

    VictorZed

    Joined:
    Dec 24, 2015
    Posts:
    22
    There is progress, but the fact is that I do not use ECS and the Job System, and all operations take place in one thread (main thread unity), I write code so that there are minimal processing costs ....
     
    Litwin likes this.
  20. ixdeveloper

    ixdeveloper

    Joined:
    Jan 5, 2016
    Posts:
    10
    Nice to see someone else picking up RakNet! We have been using it for two years in a cross platform application (iOS and HoloLens), and it's been very stable and performant. Are you planning to look into the network layer as well? Ideally, I'd like to see something that is not sensitive to firewall settings etc. Maybe run the traffic as TLS over port 443?
     
    Joe-Censored likes this.
  21. VictorZed

    VictorZed

    Joined:
    Dec 24, 2015
    Posts:
    22

    Before I started using RakNet, I tried to make a prototype of a multiplayer game using a new transport level, but then I realized that there was no documentation for it and I also took RakNet as an example
     
    Joe-Censored likes this.
  22. F-R-O-S-T-Y

    F-R-O-S-T-Y

    Joined:
    Mar 22, 2013
    Posts:
    236
    @warfaredev, @ixdeveloper Have you tried using Dark Rift 2? If you have, how would you compare these 2 frameworks?
     
  23. VictorZed

    VictorZed

    Joined:
    Dec 24, 2015
    Posts:
    22
    I have not used Dark Rift 2
     
  24. ostermannjan

    ostermannjan

    Joined:
    Apr 11, 2019
    Posts:
    1
    @warfaredev nice job, I am currently playing around with raknet :D Can I ask, how do you instantiate gameobjects over the network? Or does everyone spawn everything locally and you sync them by unique ids, or something like that?
     
    VictorZed likes this.
  25. VictorZed

    VictorZed

    Joined:
    Dec 24, 2015
    Posts:
    22
    I create the objects first on the server, set the properties for it, and then send the client information about the created object (asset id, network id, position, rotation)
     
  26. ixdeveloper

    ixdeveloper

    Joined:
    Jan 5, 2016
    Posts:
    10
    VictorZed likes this.
  27. ixdeveloper

    ixdeveloper

    Joined:
    Jan 5, 2016
    Posts:
    10
    Haven't tried it either. Looks quite promising - although in our case we do like the ability to tweak the server ourselves with RakNet.
     
    VictorZed likes this.