-
Notifications
You must be signed in to change notification settings - Fork 437
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
Allow processing of NetworkVariable
delivery as a whole at Tick update
#3195
Comments
The documentation has this section that explains the best way to get the functionality that you're describing. Is there a particular reason that RPCs do not work for your use-case? |
@EmandM Like the Documentation described, the variables that control the whole app behavior and need to update continuously and synced not only to connected clients but also late-join clients are best modeled as |
Hi @babaq, Hmm... I "think" I understand what you are trying to achieve here and there might be some details I am missing...so I am going to repeat a summary of what you are trying to achieve in order to make sure I don't provide you with an invalid/not pertinent solution. If I understand you have some form of industrial/research application where a client would visualize changes to say an object (physical or simulated) that is represented by (at a minimum) one or more NetworkObject(s) that has/have NetworkBehaviour components that could have several NetworkVariables per NetworkBehaviour component. The issue you are encountering is that not all NetworkVariable update messages, I also want to clear something up with NetworkVariables and when they are received and processed relative to one another.
So, there will always be (at a minimum with server write permission NetworkVariables):
However, as mentioned messages are batched together at the end of the frame into a "single batch message" and they are grouped together based on the delivery type used. NetworkVariables use (by default) Which the second question I have is if you are synchronizing when you update NetworkVariables (i.e. registering for NetworkTickSystem.Tick will trigger on each network tick and then checking at this point in time to determine if changes need to be made to any NetworkVariables or not)...or asked differently...at what point do you make changes to NetworkVariables relative to the player loop and relative to the other NetworkVariables and have you gathered any metrics (i.e. when you change a NetworkVariable what tick was it changed on) as to when the staggered NetworkVariable updates are occurring? I have several possible approaches, but I think the above should be a good starting point to begin to figure out what could be the best solution for your project's needs (based on your response as to whether I am fully understanding the issue at hand, when you are changing NetworkVariables, and if you are synchronizing when you are changing NetworkVariables to occur at the beginning of a tick or in some other fashion to assure you don't apply changes at the end of one tick and beginning of the next). |
Is your feature request related to a problem? Please describe.
The Documentation has stated clearly that NetworkVariable message delivery to peers in the network are not guaranteed to be received as a whole. This is also true for the deprecated
UNET
which we have confirmed by setting[SyncVar]Visible = true
to turn on two object in the same frame. On Server/Host, we can confirm two object always show up in the same frame by recording all rendered frames (Unity Recorder), but on Client, recorded frames show that some times they appear in the same frame, but other times, they appear one by another in successive two frames.This is a fatal flaw for our application because we need to measure the time when a object show up on display, if the NetworkVaraible updates are not processed as a whole, objects will be rendered at different frames, and the timing will have jitters based on frame rate.
Our old solution is to "frame" the message delivery, so before
UNET
start to preparing delivery ofSyncVar
, we first send aFrameStart
message and immediately flush the network buffer, then letUNET
doing it's work, and after that we send aFrameEnd
message to close the whole message delivery.On Client side, if
FrameStart
received, it will spin polling the network buffer untilFrameEnd
received or a timeout passed. In this way whenever we think a critical frame happens, we add framing of messages, and the critical frame will be rendered the same across network.Describe the solution you'd like
Now, we are migrating to Netcode, and wandering if this is also a useful feature to others. From a user perspective, it would be nice to have this in Netcode:
Describe alternatives you've considered
a straightforward migration of our old solution would be using
LateUpdate
to add framing message, and also the spin polling logic inPreUpdate
, but it would block main thread. The best place to add this functionality is the network thread, because the only requirement is to make sure all updates from server are received and transferred to main thread as a whole. I am not sure this need to modify low levelUnity.Transport
or we could harness theINetworkUpdateSystem
to add this functionality to the Netcode.Any suggestions are appreciated.
Additional context
Add any other context or screenshots about the feature request here.
The text was updated successfully, but these errors were encountered: