I’m having trouble in understanding that how can i know which was the player that tapped another player object. I can’t call [command] function from the clicked player object because the player who clicked it does not have authority over it.
private void OnMouseDown()
{
if (isLocalPlayer)
{
// Debug.Log(netId);
return;
}
else
// Debug.Log(netId);
Cmdsendtoserver(netId);
Debug.Log("Button Pressed");
}
[Command]
void Cmdsendtoserver(NetworkInstanceId nid)
{
NetworkServer.FindLocalObject(nid).GetComponent<Image>().color = Color.red;
Rpctotheclient(NetworkServer.FindLocalObject(nid));
}
[ClientRpc]
void Rpctotheclient(GameObject rec)
{
rec.GetComponent<Image>().color = Color.red;
}