Hey guys, need help with this as I’m struggling badly for days.
I have client-authoritative movement in my game. My player has Client Network Transform attached.
I have pick-upable swords in my game, they also have Client Network Transform.
When player picks-up sword it works as it should, gets synced properly. I’m just setting position and rotation on the sword client-side.
The problem occurs when another player picks-up the said sword after it was dropped.
When I’m changing owner, it throws this exception
Client wrote to {typeof(NetworkVariable<>).Name} without permission. No more variables can be read. This is critical.
As you can imagine, I am a little confused, because I don’t use NetworkVariables. However, what I’m guessing is happening is when I’m changing the owner, the sword was still syncing rotation and position (it has rigidbody, so it falls, so it still gets updated), and when the server was getting those updates without someone in authority, it threw the exception.
The code itself for changing ownership is very straightforward
[ServerRpc]
public void ChangeOwnershipServerRpc(NetworkObjectReference reference, ServerRpcParams serverRpcParams = default)
{
if (reference.TryGet(out var networkObject))
{
networkObject.ChangeOwnership(serverRpcParams.Receive.SenderClientId);
}
}
I’m looking for a workaround of some sort. Feel free to ask any questions as I’m not the best at explaining.
Thanks in advance.
PS. Despite it being ‘critical error’ it doesn’t seem to break anything. (although I have not yet found a way to simulate ping)