Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Join us on Dec 8, 2022, between 7 am & 7 pm EST, in the DOTS Dev Blitz Day 2022 - Q&A forum, Discord, and Unity3D Subreddit to learn more about DOTS directly from the Unity Developers.
    Dismiss Notice
  3. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

SUPER NETCODE - Networking Made Simple

Discussion in 'Multiplayer' started by SVTeam, Dec 28, 2020.

  1. SVTeam

    SVTeam

    Joined:
    Jul 2, 2017
    Posts:
    10


    About
    Super Netcode is an easy-to-use networking solution for Unity for programmers and non-programmers. It comes with code examples, YouTube tutorials, and support from the developer. Entire source code is included without DLL's, it works with IL2CPP, .NETCore and can be compiled without Unity for standalone fully authoritative dedicated servers. Connections can be established across different platforms including Mobile and PC. You host your own servers, there are no hidden fees or plans, once you have the netcode you have everything you need.

    Low Level Transport
    At its core is the low level transport over UDP written from scratch which supports reliability, encryption, authentication, compression, P2P, Mirror compatibility, accurate timings, and much more. To get familiar with the API, check out the documentation and examples that come with the asset. If you're comfortable with coding, you can only use the low level transport and write your own spawning and synchronization logic, or you can use the provided network component system that was built on top of the transport.

    High Level Network Component System
    With the network component system, you can easily spawn and synchronize transforms, rigidbodies and animations with no coding required. There is no distinction between servers and clients, the system allows any kind of network architectures including mesh networks, you just need to decide which peers get authority over which objects, and the system does the rest. There are several already written components for you to use for synchronizing transforms, rigidbodies and animations. These components use smooth interpolation and only send updates when necessary to save on bandwidth. You can also extend the system by writing your own components which handle synchronization in the way you want. For a quick start guide on how to use the network component system, check out the youtube tutorial.

    Support
    Since we use the netcode in our games, we plan on maintaining it, adding features and offering support for the indefinite future. So go ahead, get the asset, try it out, and if you have any questions, suggestions, or if you just want to showcase what you've done with it, feel free to use this thread, discord, email, or add me on discord directly (Casper#8159) and i will help you out.
     
    Last edited: May 21, 2021
  2. Gekigengar

    Gekigengar

    Joined:
    Jan 20, 2013
    Posts:
    654
    This looks incredible!

    How does input works? Is it server authoritative?
    Any input predictions & rollbacks?

    Is there any lag compensation, reconciliation?
     
    BetaMark likes this.
  3. SVTeam

    SVTeam

    Joined:
    Jul 2, 2017
    Posts:
    10
    Yes, you can build and run your own servers. There is no distinction between servers and clients within the netcode itself, you can do anything with the received messages, so if you're writing a server, the server would handle assigning authorities, spawning players, relaying messages, etc. It's completely up to you how you want to use it.

    If you're using a character controller to move the player locally, you can add a network transform component on it, give it authority and it will synchronize itself across the network on every peer that has the same player spawned. You can also automatically spawn players using the spawner component. If you want to send custom messages, you can either do it via the low level transport which sends global messages, or the network component system which sends messages directly between components.

    The network transform component does both interpolation and extrapolation based on the data it receives. Depending on how you configure it, it will attempt to predict future positions in cases where there are lost or delayed packets, or if the configured delay is larger than the round trip time. If too much time elapses without any updates it will rollback to the last known position and wait for updates there. This results in perfectly smooth movement even on bad network conditions both for transforms and rigidbodies.

    Because the transform component uses accurate timings, any minor lag spikes will not effect the movement of the object as extrapolation/prediction will kick in and compensate for it. This also means all peers will see the object in the same position regardless of what their RTT/ping is. So if you do hit detection on both the client and the server, the differences should be minimal.
     
  4. SVTeam

    SVTeam

    Joined:
    Jul 2, 2017
    Posts:
    10
    Version 1.5 released.
    • Stability improvements and bug fixes.
    • Arena example now uses Component System with a few physics objects players can kick around.
    • Much better compatibility between Low Level Transport and High Level Component System so both can be used together.
    For a full list of changes, see the changelog.
     
  5. gtk2k

    gtk2k

    Joined:
    Aug 13, 2014
    Posts:
    231
    It may seem difficult, but I hope WebGL will be supported in the future.
     
  6. SVTeam

    SVTeam

    Joined:
    Jul 2, 2017
    Posts:
    10
    There are several features planned, and one of them is indeed WebGL support. It's still a while until it gets added, but once it does, Low Level Transport will use either WebSockets or WebRTC internally for WebGL builds. Out of those two, WebRTC seems like a more likely candidate as it can work via UDP.
     
    gtk2k likes this.
  7. gtk2k

    gtk2k

    Joined:
    Aug 13, 2014
    Posts:
    231
    How many max people can be connecting at the same time?
     
  8. SVTeam

    SVTeam

    Joined:
    Jul 2, 2017
    Posts:
    10
    You can have as many connections as your machine can handle. The Low Level Transport has been tested to work with over 10k encrypted connections on a small VPS (t2.micro on AWS).
     
    Hojou and gtk2k like this.
  9. SVTeam

    SVTeam

    Joined:
    Jul 2, 2017
    Posts:
    10
    Version 1.6 released.

    Low Level Transport remains mostly the same with the biggest improvement being the calculation of timestamps of timed messages. This will now drastically reduce jitter on network transforms.

    High Level Component System internal messaging system has been completely rewritten and simplified. You can now safely connect multiple clients together into a mesh network for faster delivery of messages. Even if the network you have created contains cycles, the system will detect them and stop packets from looping forever. For example, if you have a classic server/client architecture, you can also connect several clients directly to each other via P2P which will allow the system to deliver packets much faster rather than packets going through the server.

    A new NetworkAuthority component has been added that can manage authority over several components for you. The update also includes several bug fixes and improvements. For a full list of changes, see the changelog.

    As always, if you have any questions, suggestions or feature requests let me know, i'm happy to help.
     
    Joe-Censored and gtk2k like this.
  10. Gekigengar

    Gekigengar

    Joined:
    Jan 20, 2013
    Posts:
    654


    Hello, I am finally thinking of getting Super Netcode for my next project, can I see a video on how accurate lag compensation is for collider hit detections on various simulated latency/packet loss? If this works nicely, it will be worth getting to cut down a lot of complications and production time on the netcode side for competitive shooters!
     
  11. SVTeam

    SVTeam

    Joined:
    Jul 2, 2017
    Posts:
    10

    Here is a video showcasing interpolation, rollback mechanisms and lag simulator. Version 1.7 with these features should be published in a couple of days.

    To make lag compensation more accurate, you can increase the send rate of your transforms which will result in more updates being sent and more accurate rollback, but your transform will consume more bandwidth as a result.
     
    elias_t, Gekigengar, zyzyx and 2 others like this.
  12. gtk2k

    gtk2k

    Joined:
    Aug 13, 2014
    Posts:
    231
    Good Job!!
     
  13. SVTeam

    SVTeam

    Joined:
    Jul 2, 2017
    Posts:
    10
    Version 1.7 released.

    With the new lag simulator found in the NetworkHost inspector, you can simulate latency and dropped packets to test how your game performs under bad network conditions.

    NetworkManager now has a rollback mechanism which allows you to rewind time on transforms to a particular time in the past. This is useful for lag compensation on servers when resolving hits received by clients. When the server receives a hit, it can rewind time to when the hit was made, check if the hit is valid, and then continue.

    NetworkSpawner can now be optionally used by anyone on the network which allows you to spawn a player object without any code. Just place the player onto the scene under the spawner and the spawner will do the rest.

    NetworkAuthority can now resolve authority ownership in mesh networks. This allows you to connect players together via P2P and automatically resolve authority without any central servers or code. If you have physics objects such as cars or boxes or other interactive networked objects in your game, authority ownership over them can be easily transferred between players.

    Vehicles and NPC's have been added to the Arena example and players can spawn them in the escape menu. The code has been significantly simplified to make it easier to learn from. When you touch a physics object, you claim authority over it which makes the physics object react instantly without having to wait for updates from the network. Similarly when you enter a car, you instantly claim authority over it which allows you to drive it around.

    Several games are in development using the netcode, some of which the developers have shown footage and screenshots for on our discord. If you're working on a networked game, feel free to showcase it, it helps prioritize what features to add.

    For the next version I'm going to look into adding WebGL support.

    If anyone has any questions, suggestions or feature requests, you can ask here on email or discord. I'm happy to help, and it improves the netcode :)
     
    DungDajHjep, elias_t and zyzyx like this.
  14. bvonline

    bvonline

    Joined:
    Feb 27, 2021
    Posts:
    54
    I am interested in your asset. I am not familiar with multiplayer games, and I am not a programmer, but understanding logics quite well. I am searching for a solution for a multiplayer game which offers me the useage of my own server, and a tool which helps me to add multiplayer functionalities by the inspector, or maybe for example by NodeCanvas or Playmaker (I own both).

    Is there a way to use your asset without the need of coding (simple use cases), by using NodeCanvas or Playmaker? Or are there already functionalities in the asset which would that make possible or will these be integrated? (I have read your asset description and documentation partly, but wanted to ask directly in detail before buying. Thanks in advance!
     
    Last edited: Jan 17, 2022
    Lars-Steenhoff likes this.
  15. SVTeam

    SVTeam

    Joined:
    Jul 2, 2017
    Posts:
    10
    Thank you for your interest. You can already synchronize objects without any coding by using high level components such as NetworkTransform which automatically synchronizes position and rotation for you. All you have to do is establish a connection using a NetworkHost which can be done by calling NetworkHost.Connect with the address you want to connect to. That should be possible with Playmaker or NodeCanvas too so a multiplayer game where you can start a server or connect to one via its IP is relatively easy to make. If you'd like to have server/room/lobby list or matchmaking however, that might require some coding for now, but an easy solution for that which will hopefully require no coding is planned too. If you need any help with networking feel free to drop by on discord, send an email or use this thread, i'm happy help :)
     
  16. dreamhst7

    dreamhst7

    Joined:
    Mar 27, 2014
    Posts:
    12
    Hello! Great job! Is there relay support? Can you link to a video where you explain how to use your system with dedicated server? Can I use your system for MMO? if so, then how many online users can one server support? If users don't have a real IP how can they connect?
     
  17. Eros96

    Eros96

    Joined:
    Sep 26, 2019
    Posts:
    6
    Hi, can I use your system for Virtual Reality?
     
  18. alvaromagnum

    alvaromagnum

    Joined:
    Dec 3, 2017
    Posts:
    10
    When there will be a new version? Does it will support webgl?
     
    Barritico likes this.
  19. Barritico

    Barritico

    Joined:
    Jun 9, 2017
    Posts:
    363
     
  20. Cathair

    Cathair

    Joined:
    Mar 23, 2022
    Posts:
    3
    Could you please provide more details regarding how does it compare against the "Netcode for GameObjects"? What does it do better?
     
  21. vastark13

    vastark13

    Joined:
    Mar 22, 2020
    Posts:
    5
    What's mean Per2Per ? it's mean if i have 2 laptop and 2 different internet connection with 2 different Public IP , i can send messages directly between this two laptop with Super Netcode ?
     
    Last edited: Oct 26, 2022
  22. r31o

    r31o

    Joined:
    Jul 29, 2021
    Posts:
    455
    p2p is a multiplayer game architecture.
    On a p2p game, instead of having a server that manages everything, every client does its own calculations (Like their movement) and tell the other clients what they made.
     
  23. vastark13

    vastark13

    Joined:
    Mar 22, 2020
    Posts:
    5
    i know this , but i mean i run p2p sample on my laptop , i am in Berlin, and my friend is in Italia and he run p2p sample on his laptop, i give him my public IP and he give his public IP to me , and we click connect together in same time , we see message connecting ..... but after 5 sec it show "Request Time Out" and we not connect together !!

    what's wrong ???

    we also set our port number same & not same but not work.
     
  24. vastark13

    vastark13

    Joined:
    Mar 22, 2020
    Posts:
    5
    i know this , but i mean i run p2p sample on my laptop , i am in Berlin, and my friend is in Italia and he run p2p sample on his laptop, i give him my public IP and he give his public IP to me , and we click connect together in same time , we see message connecting ..... but after 5 sec it show "Request Time Out" and we not connect together !!

    what's wrong ???

    we also set our port number same & not same number but not work.
     
  25. r31o

    r31o

    Joined:
    Jul 29, 2021
    Posts:
    455
    The host would need to port forward, but this is not suitable for a game, so a relay would be a good idea. I dont know if super netcode has a low level transport for that, but here are the most popular relays:
    -Steam relay: It requires you to pay a 100$ one time fee.
    -EOS relay: Is completely free.
    -Photon realtime: The charge you based on CCU (Concurrent users)
    -Unity Relay: I dont know anything about it.
     
  26. vastark13

    vastark13

    Joined:
    Mar 22, 2020
    Posts:
    5
    Thanks , but I need a way to send messages from my computer to my friend computer directly, I don't want to use any host or server between. I need a P2P connection ( direct client to client ) with public IP address , is that possible ?
     
  27. r31o

    r31o

    Joined:
    Jul 29, 2021
    Posts:
    455
    Port forward.
     
  28. vastark13

    vastark13

    Joined:
    Mar 22, 2020
    Posts:
    5
    what is that ? how to do it with unity ? is there any library ?
    i think it's not possible to connect two laptop or two mobile phone together in internet , with public IP .
     
  29. r31o

    r31o

    Joined:
    Jul 29, 2021
    Posts:
    455
    That has to be done on the host's router, is not anything unity specific.
    Basicaly, when your friend tries to connect, the router will block it, but if you open the port your game uses, your friend can connect using your public ip.
    How to do that is very router specific, so I cant help you with that.
    Thats why I said you to use a relay, which allows you to connect with an id, much more simple.