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.

Fish-Networking: Unity Networking Evolved! (FREE!)

Discussion in 'Multiplayer' started by Punfish, Jun 19, 2022.

  1. Recon03

    Recon03

    Joined:
    Aug 5, 2013
    Posts:
    825

    Curious to know more about this Grid condition...


    In TNET, we use multi channels and regions for larger worlds.. for having worlds in chunks with different regions. Does Fish Net have something like this?

    https://www.tasharen.com/?page_id=4518 its at the end of the demo called multi channels and regions.
     
  2. Punfish

    Punfish

    Joined:
    Dec 7, 2014
    Posts:
    304
    There's a variety of ways FishNet can do that.

    You can add the client to scenes as they approach them, only then showing objects in that scene. This would require each chunk to be a scene.

    Grid condition is a loosely based distance check that will make objects appear as you get closer. This would be automatic.The same applies for the Distance condition except it's more precise but cost more performance. Note: properly marking objects as static can also boost performance.

    Match condition will only show objects or players in the same match. To mimic the video you would add players to the match for the chunk they are nearing. So if your world was divided into four chunks you would add the player to their chunk's match, and probably the whatever chunk they are nearing.

    Lastly, you can combine any number of conditions and even make your own. Let's say you have chunks of larger worlds and you want to add the player to them manually, but you also want to only show close objects in that chunk. You could use the match condition to add the player to the chunk, and also the grid or distance condition to automatically update for nearby objects. You do not incur the cost of the automatic/regular updating conditions, or as we call them timed, when the non-timed conditions such as Match are not met.

    Here's a demo of the grid condition.
    230331-10-40-793.gif
     
    Last edited: Mar 31, 2023
    toddkc likes this.
  3. saskenergy

    saskenergy

    Joined:
    Nov 24, 2018
    Posts:
    14
    Hi, can you give more information on your possible changes to the new CSP? I agree that the current implementation requires a lot of boilerplate code so it was bound for more improvement. I've already written a lot of code so I would like to know more about it so I can prepare.
     
  4. Punfish

    Punfish

    Joined:
    Dec 7, 2014
    Posts:
    304
    To keep our no-break promise the old prediction is not being removed, at least not for quite awhile. The new prediction is still in works, but when the experimental versions are available it can be activated and deactivated by using a new 'developer' menu for Fish-Networking.
    . 20230402_10-57-57-083_247.png

    This is still very much being worked on but currently the differences are:
    - Previously a client could only use one replicate and reconcile per given time. For example, you could not control a CSP projectile as well a CSP player at the same time, each in their own class/object. You could get around this by controlling everything from one script, but that limitation is now removed.

    - PredictedObject(PO) is going away, and it's functionality is being covered in other ways. Currently PO configures the object for prediction and also predicts future velocities of rigidbodies. It can be overridden as well for custom prediction of future changes such as moving platforms. In the new prediction the only real use it has is smoothing, but even that is capable of being simplified to where PO isn't needed.

    - In relation to PO going away, clients run inputs/states now even for spectated objects. Previously clients were not aware of other inputs and the PO would attempt to predict them. In the new prediction the inputs and reconcile states are sent to all clients, and they reconcile/replay inputs just like you owned the object. I'd like to give users the option to predict in the future similar to PO, or simply not.
    Rocket League does something similar, and this is an example of what decaying future predicting might look like. This would be put in replicate...
    Code (CSharp):
    1.  
    2.             //md = MoveData.
    3.             if (!base.IsOwner)
    4.             {
    5.                 if (!newInputs)
    6.                 {
    7.                     md = _lastInputs;
    8.                     //Decay inputs per tick to allow light future prediction.
    9.                     md.Horizontal *= 0.9f;
    10.                     md.Vertical *= 0.9f;
    11.                 }
    12.                 else
    13.                 {
    14.                     _lastInputs = md;
    15.                 }
    16.                 //continue running replicate normally.
    17.             }
    - Using / calling prediction methods became a whole lot easier. This is what using prediction methods might look like currently...

    Code (CSharp):
    1.  
    2.         private void TimeManager_OnTick()
    3.         {
    4.             if (base.IsOwner)
    5.             {
    6.                 Reconciliation(default, false);
    7.                 MoveData md = CheckInput();
    8.                 Replication(md, false);
    9.             }
    10.             if (base.IsServer)
    11.             {
    12.                 Move(default, true);
    13.                 ReconcileData rd = new ReconcileData(transform.position, transform.rotation);
    14.                 Reconciliation(rd, true);
    15.             }
    16.         }
    17.  
    This is what it would look like now. You just call each method once passing in the data you want to use. Fish-Networking will internally sort it out if you're owner, server, ect.

    Code (CSharp):
    1.  
    2.         private void TimeManager_OnTick()
    3.         {
    4.             Replication(CheckInput());
    5.             ReconcileData rd = new ReconcileData(transform.position, transform.rotation);
    6.             Reconciliation(rd);
    7.         }
    8.  
    You can optionally skip checking input and building reconciledata if you know you are not the owner or server, and just pass in default. This is not required but could save you a small amount of performance.

    - Collecting one-time (or frame inputs) could use a buff. This bit has not been planned out yet but it would be great if developers could build their inputs in update normally and just send the results OnTick. EG: right now you may have to cache that jump input was queued and assign it to your built data in OnTick. I'd like to make it so you can just modify your data in Update and skip the input caching.

    Odds are you will still be required to make your own 'MoveDatas' and reconciles. This is not something we are incapable of doing automatically but by putting this in the users hands it allows much more customization and better performance gains. If we did not know specifically what needed to be reconciled we would have to send everything.

    Right now the focus is better prediction and easier setup. Eliminating PO and running inputs for all objects rather than just owned is a big step towards this direction.
     
    Last edited: Apr 2, 2023
    saskenergy and rxmarccall like this.
  5. saskenergy

    saskenergy

    Joined:
    Nov 24, 2018
    Posts:
    14
    Thanks for responding! When I started out Fish-Net, I was actually under the impression that other clients also run inputs from the simulation (I later found out that it wasn't this way). It's good that the new redesign is going in that direction.

    I'm guessing that with the other clients simulating input themselves, you can actually save bandwidth by not needing something like NetworkTransform and NetworkAnimator anymore? Since animations will be driven completely by input now, there's no need to sync the numerous amount of parameters and animator states. For the transform, the reconcile methods already send position and rotation data.

    I think the downside of this approach is when your reconcile data is large that it shadows the bandwidth savings from removing NetworkTransform and NetworkAnimator. My current reconcile already exceeds 40 bytes of data (3 floats for position, 4 floats for rotation, 3 floats for velocity, and more). Though it is entirely dependent on the type of game being made. It would probably be heavier on clients too since they need to compute the simulation (though this shouldn't be a problem for a majority of games).

    And with how this functions, this probably won't work well with your Network LOD feature right? If some input are skipped then I can imagine this would cause issues when properly simulating.

    Yea, I currently have an input manager class that does exactly this. It reads input in Update and caches them till the next OnTick call where I then flush the cache. It would be helpful if it comes natively.

    This is just a suggestion but what if we ditch the reconcile data struct entirely? Fish-Net already has mechanisms in place that does this through SyncVars. Can't we just have the SyncVars synced with the ticks and during reconcile, revert them to that state during that tick? One benefit of this approach is that SyncVars already have delta snapshots where it only sends data if it changes. The issue with reconcile data structs is that even though only the rotation has changed, you end up sending the position, velocity, and other data that hasn't changed (Unless you are doing optimizations under the hood that don't send this).
     
  6. Punfish

    Punfish

    Joined:
    Dec 7, 2014
    Posts:
    304
    Reconciles only send if changed, but they aren't delta per property yet. You don't actually need to send reconcile each time either. Reconciles are ultimately just for corrections and you don't need to try and correct every change.

    There's a tricky line to skipping reconciles though. Let's say you send a distance object only every 10 ticks and a close every 1. The close objects would resimulate but further will have to essentially pause because they weren't able to reconcile. The odds of this being problematic on a regular basis is low but there's a chance through one object correcting and not the other that their parts interfere with each other, or don't when they should. When one incorrectly affects the others path they both become out of sync to some degree.

    Granted, this would probably fall under acceptable margin of error because you may not even notice on distance objects and it would sort itself out next reconcile, just something to consider. Either way I'd like to have the option in but deltas are a big consideration too because they are a universal buff, even outside prediction.
     
    saskenergy likes this.
  7. Recon03

    Recon03

    Joined:
    Aug 5, 2013
    Posts:
    825

    Is it possible to make a small demo, example, of what I showed in that video? Just so i'm more clear. or iterate further. Not sure if I follow.


    The Grid condition, I understand completely so that is nice, that you added this.
     
  8. Punfish

    Punfish

    Joined:
    Dec 7, 2014
    Posts:
    304
    I don't know exactly what they're doing in that video, it does not really explain the process. The GridCondition or DistanceCondition alone should get the job done. The MatchCondition(or custom) would just be for extra CPU optimizations.
     
  9. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    8,583
    tested fishnet briefly, as i need networking for a 2019.4 project..

    After some initial errors, missing references in fields (maybe due to older unity version?)
    got it working and it seems good!

    I like it that you can apparently freely "sprinkle" network components in children go's also.

    Couldn't really find any "getting started" tutorial from docs?

    Like how to make basic features, minimal player movement, pickup objects or so.
    VR related guide/tutorial would be nice too.
     
  10. Punfish

    Punfish

    Joined:
    Dec 7, 2014
    Posts:
    304
    I do not have VR yet so there won't be any official tutorials from me on that. I do believe some exists on YouTube though.
    Here's a collection of additional third party learning resources that have been vetted: https://fish-networking.gitbook.io/docs/manual/tutorials
    You can find written, example projects, and video series.
    I know for sure at least some cover basic content.
    PS: the errors were probably the initial setup of the default prefabs reference missing. That's pretty common and shouldn't be an issue later.
     
  11. Punfish

    Punfish

    Joined:
    Dec 7, 2014
    Posts:
    304
    Congrats to Vona Soft on another release, and choosing Fish-Networking!

    FAS: Fight Action Sandbox:
    FAS is a unique turn-based fighting game where you design your characters and their abilities. Fight against AI or friends!
    Steam: https://store.steampowered.com/app/2302820/FAS_Fight_Action_Sandbox/


    Additionally, now is a good time to announce that the Prediction V2 is just about ready for public testing! This update will bring much more reliable prediction which is less code and less components, as well less used bandwidth! Prediction V2 will also have more options, especially those beneficial to kinematic or velocity change controllers.

    We'd like to have the new prediction available to the public ideally within a week, perhaps two at most. The old prediction system will still be available as well.
     
    DungDajHjep likes this.
  12. samvilm

    samvilm

    Joined:
    Jan 17, 2021
    Posts:
    40
    What server hosting would you recommend I use with fishnet? I'm looking for the easiest solution.
     
    Last edited: May 19, 2023
  13. Punfish

    Punfish

    Joined:
    Dec 7, 2014
    Posts:
    304
    There are many options but if you're looking for east we're a big supporter of PlayFlow
    https://playflowcloud.com/

    They have a free tier, their paid pricing is fair, and I'm personally aware of several large releases that successfully launched and scaled on PlayFlow.
     
    DungDajHjep likes this.
  14. samvilm

    samvilm

    Joined:
    Jan 17, 2021
    Posts:
    40
    Could you give some names that have used it so I can check them out?
     
  15. Punfish

    Punfish

    Joined:
    Dec 7, 2014
    Posts:
    304
    Check out my showcase page on the docs. The title sponsored by lions gate, gamestop, ect used PlayFlow and FishNet.
     
  16. Punfish

    Punfish

    Joined:
    Dec 7, 2014
    Posts:
    304

    Many are already aware Fish-Networking is the best in class for scalability among free Unity networking solutions.

    Did you also know we also have a FREE MMO Kit to leverage that power?

    Start your MMO today using FishMMO https://fishmmo.vexstorm.com/

    If you enjoy their work consider sponsoring them! https://cash.app/$jimdroberts
     
    Last edited: May 29, 2023 at 2:16 AM
  17. Punfish

    Punfish

    Joined:
    Dec 7, 2014
    Posts:
    304
    After sitting on 3.5.8 for awhile we have another stable release!

    This version brings a ton of performance improvements, primarily targeting the CPU and memory usage. Compared to 3.5.8 you can expect significantly less garbage collection and CPU burst which will improve over-all scalability.

    Given the majority of our core features are implemented it felt like a good time to put more focus towards bug fixes. With the help of the community we've been able to isolate and address a considerable amount of less obvious bugs, and some more rare edge case ones as well.

    Several small features have also been added to make everyone's life easier. Prediction v1 now allows the server to run replications without an owner, this can be ideal for a number of scenarios but prefabs which could be players or NPCs is a common use. You can now use SetParent/UnsetParent on NetworkObject references; this will validate your target and output debug if your target is not network compatible. There's a few other QOL improvements as well, including git package support thanks to @NonPolynomialTim(FishNet Discord).

    For a full changelog please check out https://firstgeargames.com/FishNet/changelog.html This release will be submitted to the asset store tomorrow.

    PS: yes this means prediction v2 is being worked on again.
     
  18. Sandiford

    Sandiford

    Joined:
    Aug 21, 2015
    Posts:
    3
    Hi. Installing FishNet with 2022 LTS gives warnings:

    warning CS0618: 'Physics.autoSimulation' is obsolete: 'Physics.autoSimulation has been replaced by Physics.simulationMode'

    Is this normal?

    I also didn't get DefaultPrefabObjects until I mucked about with DefaultPrefabObjects.cs (uncommented line 15) and recompiled.
     
  19. Punfish

    Punfish

    Joined:
    Dec 7, 2014
    Posts:
    304
    The DefaultPrefabObjects thing is unusual, it should auto generate the file regardless. That menu just lets you manually create the file but FishNet also does it automatically internally. The line has been commented out for quite awhile now so this perhaps was just a fluke.

    Unity obsoleted the physics method and they're just letting you know. The warning is harmless. I'll make sure it's resolved in a future release.
     
  20. Sandiford

    Sandiford

    Joined:
    Aug 21, 2015
    Posts:
    3
    Thanks for the reply.

    Decided to do some testing. With 2021.3.23f1 it works as expected, no warnings.

    With 2022 LTS, there are warnings, and no prefab list is initially generated. However simply creating a new script triggers the creation of the prefab list. Perhaps any compile event sets it off - just a guess.

    Cheers
     
  21. Barritico

    Barritico

    Joined:
    Jun 9, 2017
    Posts:
    366
    Hello.

    I have a request to make for you. I don't know if it's possible or not, but I try.

    I'm very, very, very bad at this multiplayer thing and I want to do something very simple. I have a car game and I need a user to be able to get into another user's vehicle as a co-driver.

    To clarify more: a driving school teacher takes his student and shows him (her) how to drive. The teacher is a user from one country and the student another user from another country. The teacher drives the car and the student just listens and looks at the directions.

    Since I don't have more need than this, I would like to know if the author of FISHNET or any user reading this could help me. Of course, if necessary, I would pay for that help.

    Thank you so much.