Skip to content

When a client connects to a server all clients receive all NetworkVariables #1987

Closed
@mraue

Description

@mraue

Thanks @mraue for the update. I get your issue now. Please let me update it and re-open as it seems pretty important.

Description

Every time a client connects to a server all NetworkVariables on all NetworkObjects get synced to all clients.

Reproduce Steps

  1. Create a NetworkObject with a NetworkVariable. Add a log that tracks OnValueChanged
  2. Start a server and connect a client
  3. Connect a second client
  4. The first and the second client show the OnValueChanged log

Actual Outcome

All connected clients receive a NetworkVariable update.

Expected Outcome

Only the second client connecting should receive the NetworkVariable data.

Additional Context

During the internal void SendSpawnCallForObject(ulong clientId, NetworkObject networkObject) for the NetworkObject to spawn, we mark:
networkObject.MarkVariablesDirty(true);
This causes the NetworkVariable to be considered dirty for all clients. As a result, the NetworkVariable gets serialized to all clients.
The difficulty lies with the fact that current Netcode for GameObjects doesn't have a way to mark dirtiness for some clients only. This will require a bit of refactor.

Metadata

Metadata

Assignees

Labels

priority:highThis issue has high priority and we are focusing to resolve itstat:importedStatus - Issue is tracked internally at Unitytype:bugBug Report

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions