Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

How is RPC execution order determined on remote clients receiving RPC? #3735

Copy link
Copy link
@zachstronaut

Description

@zachstronaut
Issue body actions

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

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    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

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.