Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question [FishNet] RigidBody Collisions

Discussion in 'Multiplayer' started by ATMLVE, Feb 11, 2024.

  1. ATMLVE

    ATMLVE

    Joined:
    Jun 11, 2023
    Posts:
    68
    I've been trying to get Rigidbody collisions to work well with fishnet. Nothing I've done works perfectly in all cases and there seems to be two or three ways to do it, each with their own subset ways of doing things - there's tons of little settings here and there which I find references to in two of the three sources I find when searching on this topic. I'm just confused on the whole fishnet physics thing and would really like some clarification.

    So I have a box and a Rigidbody/AddForce physics-based character controller. For simplicity's sake, the box is floating with no gravity. What I want is for the player to run into the box and it moves.

    When I just attach a network transform to the box, it jitters a good bit for the client when hit. Also, clients exert a weird amount of force on the box - they can sprint into it and it might not move until five seconds later, or it might move just a little bit, or not at all - all depending on the settings I have across the code, the network transform, and the rigidbody. The server/client will always exert the correct and expected force.

    I then tried the PredictedObject way, and got similarly not-quite-it results. Again the client exerts a strange amount of force on the box - they can run into it but exert very little force on it, barely nudging it at all (The connected server/client can just bump it and send it flying, correct behaviour). If I change a few settings around, I can end up making it work literally the opposite way - the client will run into the box and send it flying, while on the server it only moves a little bit. With some settings a certain different way I can get it rubber banding (I forget whether on the client or server, I've tried so many settings combinations).

    Then there's the whole fishnet prediction v2 thing, which is apparently not part of the current asset store version. I tried downloading fishnet version 4 from github but there were a bunch of namespace errors so I had to revert.

    Anyway all that aside there are a bunch of different physics collider things going on with fishnet and they're documented individually, but their relationships with each other aren't clear. Do you need a network transform and PredictedObject together? Which one is better for these types of rigidbody collisions? Do you need to replace all FixedUpdate instances with TimeManager_OnTick()? And where can I learn how to properly install Fishnet version 4 from github including the missing namespaces?
     
  2. Punfish

    Punfish

    Joined:
    Dec 7, 2014
    Posts:
    383
    While V4 is not on the asset store yet it is in stable release; in a couple weeks we'll be sending it up.

    To get V4 first delete your FishNet folder and import of course from the Github. There are some significant changes because it's a major release which means API changes. You can learn how to fix each error message here: https://fish-networking.gitbook.io/docs/manual/general/changelog/break-solutions

    Far as your problem goes, Prediction 1 is no longer being updated. Prediction 2 is still 'experimental' but it works much better P1 with more features, and we're only a couple minor bugs away from taking it out of experimental. In other words, strongly recommend using P2.
     
    Last edited: Feb 11, 2024
    ATMLVE likes this.
  3. ATMLVE

    ATMLVE

    Joined:
    Jun 11, 2023
    Posts:
    68
    Thank you. Is the custom physics time step needed for accurately synced rigidbody collisions?
     
  4. Punfish

    Punfish

    Joined:
    Dec 7, 2014
    Posts:
    383
    Setting physics to timemanager on the timemanager component is required if that's what you mean.
     
    ATMLVE likes this.
  5. ATMLVE

    ATMLVE

    Joined:
    Jun 11, 2023
    Posts:
    68
    So I finally managed to get V4 implemented and prediction V2 working. However I'm still hitting one of the same snags I did originally - addforce on the external client is just always less than the server/client for some reason.

    On my character controller I have broken it down to one single line of code of rb.AddForce. Through debug logs I've confirmed that both clients run the same numbers with the same code at the exact same rate (the fishnet time manager tickrate). Yet the server/client moves exponentially faster than the external client. I'm out of leads as to where to look.
     
  6. QuitsDoubloon

    QuitsDoubloon

    Joined:
    Dec 23, 2018
    Posts:
    5
    I just upgraded from V3 to V4 and without prediction my clients move at about twice the rate of the server / what they did before the upgrade. They seem to update at the same frequency and log the same velocity but still clearly move at (I'm guessing) twice the rate of the server. They also apply gravity at double speed making me thing that forces are being applied twice?

    Edit: This problem only appears after enabling PredictionV2 without implementing the necessary logic behind it.
     
    Last edited: Feb 16, 2024
    Punfish likes this.
  7. ATMLVE

    ATMLVE

    Joined:
    Jun 11, 2023
    Posts:
    68
    I've made some progress since my post, a lot of my errors did come from a lack of understanding, but I started from scratch with Prediction V2 which works well when you know how to reign it in (I still don't, I ask on discord)
     
  8. Punfish

    Punfish

    Joined:
    Dec 7, 2014
    Posts:
    383
    We just launched new components, NetworkTrigger/NetworkCollision which can help out a ton if you are using said triggers/collisions.
     
    ATMLVE likes this.