Search Unity

  1. Unity 2019.1 is now released.
    Dismiss Notice

Net Rewinder - Network-System-Independent hitbox lag compensation system

Discussion in 'Assets and Asset Store' started by CodeBison, Nov 24, 2015.

  1. CodeBison

    CodeBison

    Joined:
    Feb 1, 2014
    Posts:
    202
    [Update] Net Rewinder is now available on the Asset Store here.

    Net Rewinder
    is a server side hitbox rewinder / lag compensator for use with any networking library. It focuses on doing only one thing, and doing that one thing simply and well. One function call rewinds hitboxes (your selected transforms) to exactly where they were at the time you specify. You can use any representation of hitboxes you want, any networking library, and any hit detection routines you want. You can run whatever tests you want against them, and then restore them to their original positions with another call.

    Features:
    • One-button setup for most use cases
    • One-call hitbox rewind
    • One-call hitbox restore
    • Full source code included
    • Use any hitbox system
    • Zero update allocations
    • Supports 2D and 3D - anything with a transform can be rewound
    • Preview demo scene with commented code
    • Works with any network library (UNet,Photon, Bolt, Forge, etc)
    • Works with UFPS and other FPS frameworks.
    Links:
    Screenshots:

    Single character preview


    Multiple (125) character preview


    Sample code used for the preview screenshots above


    Net Rewinder freshly added to an FPS character


    One click later​

    Note:
    This asset requires some programming skill to use effectively. Hitboxes themselves are not implemented in Net Rewinder. This is to allow you to use whatever hitbox implementation you want (eg UFPS). This asset simply (and I mean simply!) takes care of rewinding so you can do server-side hit checks for networked FPS and other fast-paced network games.
     
    Last edited: Dec 14, 2015
  2. Brent_Farris

    Brent_Farris

    Joined:
    Jul 13, 2012
    Posts:
    881
    Hi there :)

    I'd be interested to see how it is working with Forge. Feel free to hit us up (support@beardedmangames.com), maybe we can help to see if there is a way we can make this streamlined with Forge :D
     
    jasonMcintosh and DanielSnd like this.
  3. phil-harvey

    phil-harvey

    Joined:
    Aug 27, 2014
    Posts:
    59
    Do you have to manually add each transform to the list? is there a way of adding a GameObject and then all tagged transforms are then added?

    no need to comment, just read the documentation. A script is added to each object and then in the script you add the hit boxes. So I guess once created all hit boxes in that script are updated.

    What is the expected price?
     
    Last edited: Dec 1, 2015
  4. CodeBison

    CodeBison

    Joined:
    Feb 1, 2014
    Posts:
    202
    By default everything with a Collider under the gameObject will be added to the list, though if people would find a tag system easier I could certainly add that as an option. Grabbing all the colliders by default just seemed the most natural behaviour to me.

    Expected price is $25. It's under review by the asset store team right now.
     
  5. CodeBison

    CodeBison

    Joined:
    Feb 1, 2014
    Posts:
    202
    Farrisarts, I sent an email a while back. Let me know if it didn't show up and I can resend.

    Cheers!
     
  6. Brent_Farris

    Brent_Farris

    Joined:
    Jul 13, 2012
    Posts:
    881
    No problem, we will be checking our email soon, lots of vacations and such have interrupted our email checking (high volumes). Either @Cranick or I should be getting to it soon :D
     
  7. CodeBison

    CodeBison

    Joined:
    Feb 1, 2014
    Posts:
    202
    Sounds good. Glad you guys can get some time off - it's easy to miss that.
     
  8. imgodot

    imgodot

    Joined:
    Nov 29, 2013
    Posts:
    170
    CodeBison, What kind/how much overhead is incurred with the rewinder?
    For a multiplayer, FPS game with fast movement and lots of shots fired, can it keep up without bogging down the server, esp. if the server is also hosting a client?
    Are there any situations where the rewinding is non-deterministic or you might get different results for different clients shooting at the same target?
    Any flaws/caveats not referenced in the documentation?

    Thanks.
    -- Paul
     
  9. CodeBison

    CodeBison

    Joined:
    Feb 1, 2014
    Posts:
    202
    HI
    Hi Paul,

    Net Rewinder is quite performant. You should have no trouble at all using it in a fast-paced FPS game. I've tested rewinding 125 npcs with 15 hitboxes each every frame and was able to run the simulation at 45-55FPS on my system, while rendering all 125 npcs and visualizations of their hitboxes (screenshot 2 above). Obviously, in a real FPS, you won't be rewinding every frame, you won't be displaying visuals for your hitbox rewinds, and you'll rarely be rewinding more than a handful of characters at a time. In real-world use cases, you'll probably never see it above 1% of your frame time. Generally speaking, the raycast to determine if a bullet hits will probably be more expensive than the rewind to make sure the raycast is accurate.

    If you need more hard performance data, please let me know.

    Regarding deterministic results, you have complete control over how accurate Net Rewinder is. Since it's run on the server, it gets its data from your authoritative copy of the world state. If you use the default settings (appropriate for most use cases, though massive simulations with thousands of entities might need different settings), it will record the position of every hitbox every single physics frame. This means that you can rewind any character to the exact historical position and orientation they had at any timestep in their history. In the unlikely event that you need to reduce the recording fidelity for any reason (thousands of agents etc), rewind requests for timesteps between the snapshots will be interpolated from their neighbouring timesteps, and may diverge slightly from their actual historical values. It should be noted, however, that hits from all clients will be tested against the same data, so they'll all get consistent hit/miss results. The one exception to this is if the server is also a client. Since the local host won't be using rewinding, they'll be tested against live data rather than the recorded results, and so will have a slight advantage in this case.

    There are no Net Rewinder specific flaws/caveats I'm aware of beyond what's mentioned in the documentation. There are obviously issues common to all network multiuser applications that will apply, but those are not unique to Net Rewinder. The most significant of these is that, due to the nature of predictive movement and interpolation used in fast-paced network games, not all users see the same presentation of the game world. They see close approximations, but there will always be points where their view will differ slightly from the server's authoritative copy, even with the best compensations in place.

    Sorry, I've written a bit of a novel here. Hopefully that helps with your questions. If not, please let me know.

    Cheers,

    Cameron
     
  10. imgodot

    imgodot

    Joined:
    Nov 29, 2013
    Posts:
    170
    Cameron, Thanks for that reply. Appreciate the detail.
    One of my issues with multiplayer is the scenario where player A is aiming for player B; player A draws a bead, shoots, and scores on Player B but player B's view shows player A still turning toward them and, though not quite there, BOOM!
    Unfortunately, Rewinder can't solve that.

    However, as I think about it, I think I am confused about when I would use Rewinder.
    If an authoritative server is running the simulation of events and the server receives a missile_has_been_shot event/command then the position of the players and the missile are both tracked (with absolute accuracy) on the server, though the representation on the clients may disagree due to lag. If the server says a missile hit a player, that is accurate and there is no need for rewinding is there?
    Is Rewinder only for hit-scan type weapons?
     
  11. CodeBison

    CodeBison

    Joined:
    Feb 1, 2014
    Posts:
    202
    Yes, Net Rewinder's primary usefulness would be with hitscan-style weapons. It wouldn't be much help with slower projectiles like missiles.

    The makers of MechWarrior Online wrote a good article on how they overcame the challenges of fast-paced missile combat. It touches all the core elements needed, and is very solid. One of the interesting things they consider is backdating missile launches etc to compensate for lag. It's an interesting read. Maybe you'll find it useful: http://www.gamasutra.com/blogs/Neem...ompensating_Weapons_in_MechWarrior_Online.php

    Cheers,

    Cameron
     
  12. silentneedle

    silentneedle

    Joined:
    Mar 14, 2013
    Posts:
    280
    Is it possible to use net rewinder event based/outside of the update loop?
     
  13. CodeBison

    CodeBison

    Joined:
    Feb 1, 2014
    Posts:
    202
    If you mean rewinding for hit checks, yes you can do that any time. Just make sure your event handler does both rewind and restore in the same tick.
     
    silentneedle likes this.
  14. muratvertigo

    muratvertigo

    Joined:
    Oct 3, 2016
    Posts:
    1
    Is it compatible with Photon cloud or only custom server?
     
  15. CodeBison

    CodeBison

    Joined:
    Feb 1, 2014
    Posts:
    202
    Yes, it will work with any networking library.
     
  16. Vandarthul

    Vandarthul

    Joined:
    Dec 23, 2012
    Posts:
    19
    Hey, just to clear any misunderstanding here. As I understand, this asset requires an authoritative server to function properly. So in a master-client structure(Photon Cloud without a server) it wouldn't properly work. Can you confirm on that?
     
  17. CodeBison

    CodeBison

    Joined:
    Feb 1, 2014
    Posts:
    202
    It will work fine with Photon. You'd do the rewinding on the master client.
     
  18. Vandarthul

    Vandarthul

    Joined:
    Dec 23, 2012
    Posts:
    19
    @CodeBison wouldn't that put a lot of network pressure on master client?
     
  19. CodeBison

    CodeBison

    Joined:
    Feb 1, 2014
    Posts:
    202
    The rewinding itself doesn't add network pressure. What adds network pressure is having any kind of server authoritative setup. If you have a client acting as the server to ensure the other clients aren't cheating, that incurs network overhead. Rewinding on the server (matter client) is just how you determine if shots are legit. You'll be doing a lot of other things on the server as well: Controlling level changes. Verifying movement validity. Handling circle of concern. Etc

    If you don't need to protect against cheating (eg if you have a fully coop experience) then you don't need a server authoritative setup. Which means you trust the client and let it take care of its own hit detection, movement, etc. In which case you have no need of things like hitbox rewinding.
     
  20. silentneedle

    silentneedle

    Joined:
    Mar 14, 2013
    Posts:
    280
    @CodeBison Could you please make it possible to setup netrewinder at runtime? Please add an AddHitbox method or add a setter for hitboxCount.
     
  21. CodeBison

    CodeBison

    Joined:
    Feb 1, 2014
    Posts:
    202
    Sure thing. :)
     
    silentneedle likes this.
  22. CodeBison

    CodeBison

    Joined:
    Feb 1, 2014
    Posts:
    202
    Okay, so I've added a couple runtime methods you can use to set up the rewinder. There's a GetHitboxes() method that does a live setup including all colliders under the gameobject, and a SetHitboxes(List<Transform>) method, that takes a list of transforms and sets the hitbox array appropriately. Both these methods call a public Init() method afterwards, which redoes initial setup of the rewinder, clearing out hitbox history etc. Note that because this method is public, you can also just manually edit NetRewinder.hitBoxes directly if you prefer, and just call Init() after.

    Does that sound like it'll do what you need? If so, I can send you an updated version if you email me at support@codebison.ca with your invoice number.

    Cheers!
     
    silentneedle likes this.
  23. silentneedle

    silentneedle

    Joined:
    Mar 14, 2013
    Posts:
    280
    Awesome, thank you! :)
     
  24. CodeBison

    CodeBison

    Joined:
    Feb 1, 2014
    Posts:
    202
    No worries, thanks for the suggestion. :)

    Version 1.2 is up on the asset store. You'll find usage info for the new functions in the docs. The sample scene also has an editor component in it that you can use to see the new functionality in action.

    Cheers!
     
    silentneedle likes this.