Skip to content

NetworkVariable ownership write permissions and ChangeOwnership race condition #3537

@zachstronaut

Description

@zachstronaut

I have a NetworkVariable with writePerm: NetworkVariableWritePermission.Owner in one NetworkBehaviour and on that same NetworkObject I have another NetworkBehaviour that uses ChangeOwnership from within a coroutine.

When ownership changes, I notice I get this error sometimes on the host:

[Netcode] Client wrote to NetworkVariable`1 without permission. No more variables can be read. This is critical. => NetworkObjectId: 95 - GetNetworkBehaviourOrderIndex(): 0 - VariableIndex: 0

The code writing to the NetworkVariable is in Update() and I have tried wrapping it with IsOwner and NetworkObject.IsOwner and neither of those prevent this error message.

It seems like maybe there is a race condition here with netcode internals?

I am using netcode 2.4.2 with a Host-Client topology. In this case a host with one additional client.

Metadata

Metadata

Assignees

No one assigned

    Labels

    stat:awaiting-triageStatus - Awaiting triage from the Netcode team.stat:reply-neededAwaiting reply from Unity accounttype:bugBug Report

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions