question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:15 (13 by maintainers)

github_iconTop GitHub Comments

1reaction
mrauecommented, May 27, 2022

I tested commenting out the line networkObject.MarkVariablesDirty(); inSendSpawnCallForObject. While the initial spawning works fine, the spawning triggered by visibility changes is then broken. The objects do not receive the NetworkVariable states.

1reaction
LukeStampflicommented, May 26, 2022

More details can also be found in the Discord conversation here

Read more comments on GitHub >

github_iconTop Results From Across the Web

NetworkVariable | Unity Multiplayer Networking
When a NetworkVariable value changes, any connected clients that subscribed to NetworkVariable.OnValueChanged event (prior to the value being ...
Read more >
Networkvariable Value does not update , cannot solve ...
Well, my very first question on a forum, and I think it's a very simple, for me embarrassing question, with a simple answer...
Read more >
Networking with Netcode: NetworkVariables, RPCs ... - YouTube
This three part series will review all major Netcode features to help guide ... location with physical interactions across clients and server.
Read more >
COMPLETE Unity Multiplayer Tutorial (Netcode for ... - YouTube
00:00 Getting Started with Unity Multiplayer (Netcode for Game ... I'm your Code Monkey and here you will learn everything about Game ...
Read more >
Unity Netcode For Gameobject - Network Variables - YouTube
In this video, we take a look into implementing a little puzzle where two players need to stand on switches to open a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found