-
Notifications
You must be signed in to change notification settings - Fork 462
Closed as not planned
Labels
stat:awaiting-responseAwaiting response from author. This label should be added manually.Awaiting response from author. This label should be added manually.type:bugBug ReportBug Report
Description
When a (non-host) client calls a Server RPC that both changes Ownership and changes the value of a NetworkVariable, that non-host client will not receive a OnValueChanged event.
public class Test : NetworkBehaviour
{
public NetworkVariable<int> test = new NetworkVariable<int>(-1, NetworkVariableReadPermission.Everyone, NetworkVariableWritePermission.Owner);
[ServerRpc(RequireOwnership = false)]
public void InitializeAndClaimOwnership_ServerRpc(int _test, ServerRpcParams _rpcParams = default)
{
NetworkObject.ChangeOwnership(NetworkManager.ServerClientId);
test.Value = _test;
NetworkObject.ChangeOwnership(_rpcParams.Receive.SenderClientId); // Remove this line, and the non-host client will receive the OnValueChanged event for the test NetworkVariable
}
}
public class Observer : MonoBehaviour
{
void SomeClientMethod(Test test)
{
test.test.OnValueChanged += (previousValue, newValue) =>
{
// Will not fire on non-host client
Debug.Log($"Previous value: {previousValue}, new value: {newValue}");
};
test.InitializeAndClaimOwnership_ServerRpc(0);
}
}
Metadata
Metadata
Assignees
Labels
stat:awaiting-responseAwaiting response from author. This label should be added manually.Awaiting response from author. This label should be added manually.type:bugBug ReportBug Report