NetCodeForGameobjects Rpc for a specific client

I’m using Netcode for GameObjects for my multiplayer game. I use this code to spawn an object in clients

[ClientRpc]
public void test1ClientRpc()
{
    GameObject ob = Instantiate(Obj,new Vector3(0,0,0),Quaternion.Euler(0,0,0)); 
}

but the problem is that it sends this code to all clients, I want it to send it for a specific client.

now I’m using this code,

[ClientRpc]
public void test1ClientRpc()
{
    if (NetId==2)
    {
        GameObject ob = Instantiate(Obj, new Vector3(0, 0, 0), Quaternion.Euler(0, 0, 0));
    }
}

it works fine but it has a problem .server still sends the code to all clients, then they check the condition and … , I want to send it only for that specific client :slight_smile:

[ClientRpc]
public void MySpecificClientRpc ( ClientRpcParams clientRpcParams )
{
    /* code */
}

For anyone else who stumbles upon this, the original poster could’ve clarified it a bit more but the documentation reads a bit down on the page:

ClientRpcSendParams’s TargetClientIds property is a ulong[] You can construct a ClientRpcParams where its Send property is equal to a ClientRpcSendParams containing a new list of clientId’s to target:

var sendParams = new ClientRpcSendParams();
sendParams.TargetClientIds = new[] { clientId1, clientId2, clientId3... };

var rpcParams = new ClientRpcParams()
{
	Send = sendParams
};