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.

Inheritaded network variable wont update on clients.

See original GitHub issue

I have this class

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Unity.Netcode;

public class RoomSync : NetworkBehaviour
{
    public NetworkVariable<int> netCurrentRoom = new NetworkVariable<int>(0, NetworkVariableReadPermission.Everyone, NetworkVariableWritePermission.Server);
    public int currentRoom = 999;
    public void Start()
    {
        if (NetworkManager.Singleton.IsServer)
        {
            netCurrentRoom.Value = currentRoom;
        }
    }
}

If I make a GameObject with a class that inherits RoomSync the NetworkVariable will change on servers but wont be updated on clients giving the error

NetworkVariable is written to, but doesn’t know its NetworkBehaviour yet. Are you modifying a NetworkVariable before the NetworkObject is spawned?

Issue Analytics

  • State:open
  • Created 5 months ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
brunoslycommented, May 11, 2023

I found on version 1.3.1. Will try later on 1.4.0 and report results.

0reactions
mtarzwellcommented, Jun 20, 2023

Hello @brunosly how did it go? Are you still having this issue? Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

NetworkVariable update before ClientRpc
Network variables should match on all clients, or at least will eventually once the updates has been received. It's worth keeping in mind ......
Read more >
NetworkVariable | Unity Multiplayer Networking
At a high level, a NetworkVariable is a way to synchronize a property ("variable") between a server and client(s) without having to use ......
Read more >
How do I update the client with server side variables during ...
I am using VS2012 and ASP.NET 4.5. EDIT: To be more specific, the problem occurs while the server is busy with the loop....
Read more >
Is it possible to pass variable from gateway scope to client ...
I have a GW timer script that is calling a script library function which updates a module variable defined within the library itself....
Read more >
CMD doesn't update environment variables even when ...
I've been setup my variables for my development environment using the Windows cmd, but it works well only the first time I set...
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