-
Notifications
You must be signed in to change notification settings - Fork 463
Closed
Labels
priority:lowThis issue has low priority and will take some time to be resolvedThis issue has low priority and will take some time to be resolvedtype:docsDocs feedback or issueDocs feedback or issue
Description
Description
How is RPC execution order determined on the clients receiving RPCs?
I have a host with one client.
I have a scene with a FruitRpcTest object and a Banana object. And I have an Apple prefab.
There are three scripts:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Unity.Netcode;
public class FruitRpcTest : NetworkBehaviour
{
public NetworkObject applePrefab;
public Banana bananaObject;
[ContextMenu("Setup Test")]
void SetupTest()
{
if (NetworkManager.ConnectedClientsIds.Count != 2)
{
Debug.LogError("Client was not connected.");
return;
}
var temp = GameObject.Instantiate(applePrefab);
NetworkObject networkObj = temp.GetComponent<NetworkObject>();
networkObj.SpawnWithOwnership(1);
bananaObject.NetworkObject.ChangeOwnership(1);
}
[ContextMenu("Run Rpcs")]
void RunRpcs()
{
var apple = GameObject.FindObjectOfType<Apple>();
apple.banana = bananaObject;
Debug.LogError("Send AppleRpc");
apple.AppleRpc();
}
}using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Unity.Netcode;
public class Apple : NetworkBehaviour
{
public Banana banana { get; set; }
[Rpc(SendTo.Everyone, RequireOwnership = true)]
public void AppleRpc()
{
Debug.LogError("Recv AppleRpc");
if (IsOwner)
{
Debug.LogError("Send BananaRpc");
banana.BananaRpc();
}
}
}using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Unity.Netcode;
public class Banana : NetworkBehaviour
{
[Rpc(SendTo.NotMe, RequireOwnership = true)]
public void BananaRpc()
{
Debug.LogError("Recv BananaRpc");
}
}SetupTest() is run on the host and then RunRpcs() is run on the client.
Client log output is:
Send AppleRpc
Recv AppleRpc
Send BananaRpc
Host log output is:
Recv BananaRpc
Recv AppleRpc
Is this reverse receive order by chance or by design?
Netcode Version 2.6.0
Metadata
Metadata
Assignees
Labels
priority:lowThis issue has low priority and will take some time to be resolvedThis issue has low priority and will take some time to be resolvedtype:docsDocs feedback or issueDocs feedback or issue