- Home /
Question by
jdetter · Jan 04, 2017 at 03:29 PM ·
networkingrpcclient-server
Standard ClientRPC not called on client
When I run my Unity server in host mode, the object spawns on the client and uses the CmdRequestUpdate()
command, which then should call a ClientRPC and a TargetRPC. The client will receive the TargetRPC call, however it never receives the ClientRPC call. I'm not sure if this is an issue or not but I'm curious if anyone knows what's going on here.
Reproducer
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Networking;
public class PlayerAttributeManager : NetworkBehaviour
{
[Server]
public override void OnStartServer()
{
Debug.Log("server attributes started.");
}
[Client]
public override void OnStartClient()
{
Debug.Log("Client attributes started.");
CmdRequestUpdate();
}
[Command]
public void CmdRequestUpdate()
{
Debug.Log("Server got request for update.");
RpcGetYourUpdate();
Debug.Log("RPC sent");
TargetGetYourUpdate(this.connectionToClient);
Debug.Log("Target RPC sent");
}
[ClientRpc]
void RpcGetYourUpdate()
{
Debug.Log("Received update.");
}
[TargetRpc]
void TargetGetYourUpdate(NetworkConnection conn)
{
Debug.Log("Target received update.");
}
}
Output with Unity 5.5.0f3
server attributes started.
Client attributes started.
Server got request for update.
RPC sent.
Target RPC sent
Target received update.
Comment
Did you find any solution to your problem? I'm having this same issue, ClientRPCs not being called.
Nope, I never found an actual solution for this particular problem.
I submitted a bug report so hopefully someone at unity will take a look at it.