-
-
Notifications
You must be signed in to change notification settings - Fork 771
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A LagCompensator Revamp #3770
base: master
Are you sure you want to change the base?
A LagCompensator Revamp #3770
Conversation
This could work in a similar way as mischa's version, only updating if the client hit the collider on their screen. it would decrease firing overhead, as your not always hitting a player, and thus dont need to update the colliders every time you shoot. however it would require more scripting from the user, as the user would need to add a different command to the clients fire function to update the collider. ^ added as UpdateTargetCollider() and DisableColldiers(). Only thing left to do is add 2d support, I think that would warrant a different script? like LagCompensator2d? |
…end trees. This is impossible to automate, and has to be added manually by the user.
…mpensatorrevamp # Conflicts: # Assets/Mirror/Components/LagCompensation/LagCompensator.cs
…sed if you want greater perf at the cost of more manual scripting.
I suggest using [ServerCallback] for Update() |
Wouldn't [Server] be better? Only difference on the docs is that it doesn't throw an error if a client calls the method, but all of the methods shouldn't be called on the clients anyways? I've only ever used [Server] myself, so I'm not sure. |
Have to use [ServerCallback] for Unity methods because Unity will call them in all contexts and we don't need the warning flood. |
Ah that makes sense. For some reason I thought the original guy meant swapping [Server] to [ServerCallback] on the Update methods I added, and not unity's one. |
Current Lagcompensator:
Supports box colliders,
Supports position & scale compensation.
Supports primitive movement systems.
Uses performance intensive methods. (addcomponent, destroy, instantiate, raycast)
Easy to script.
Very easy to implement.
Revamped Lagcompensator:
Supports any 3d collider type, including ragdoll rigs.
Supports position, rotation, and animation compensation.
Supports complex movement systems.
Optimized.
Easy to script.
May need refactoring to implement.
Animation Tracking & Compensation has been added. Note that it doesn't track or compensate for Blend Tree variables, that would be very hard to automate. you would have to manually set these in the compensated animator via script. OR edit the Lagcompensator to implement & interpolate these in Capture3d.
Usage is pretty simple, create dummy player with only trigger colliders. parent said dummy and the actual player under a main player GameObject. (may need refactoring). There's probably be a way to do this without parenting, not sure. Make sure to disable this by default, as it will be enabled when necessary by the server.
then just fill in the "tracked" fields with your actual player, and "compensated" fields with dummy player. the separated position / orientation variables are there for more complex player movement systems.
Animator compensation is optional.
Now you have 2 options for implementation, The first and easier version, await
UpdateColliders()
. you just put this before you Raycast in your servers Fire function. This also awaits a task inside of the function, not sure if its redundant.Second and more performant option,
UpdateTargetCollider()
andDisableColliders()
work together.DisableColliders()
goes at the end of your servers fire function. ThenUpdateTargetColldier
gets called if the client hits a player with their local raycast. NOT the server. i think the best way to add this is to add aNetworkConnectionToClient target
to your servers fire function, then callingawait UpdateTargetColldier(target)
before your servers raycast, if the target is not null.