I have a networking game in Unity Version 5.4.0b24, but when i call a [ClientRpc] function from server it doesnt work, gives an error like this:
Found no behaviour for incoming [ClientRpc:InvokeRpcRpcSetLayerWeightClient] on Player2@Owner(Clone) (UnityEngine.GameObject), the server and client should have the same NetworkBehaviour instances [netId=1].
ClientRpc [ClientRpc:InvokeRpcRpcSetLayerWeightClient] handler not found [netId=1] UnityEngine.Networking.NetworkIdentity:UNetStaticUpdate()
I have attached a NetworkIdentity, NetworkAnimation, and NetworkTransform to the game object, as well as my script below:
My script below was attached to the game object dynamically at run-time (dont know if that has anything to do with it). Also note that the gameobject in question is a UMA DYNAMIC AVATAR (an avatar created dynamically, see on in the asset store)
so that Start () method you see below is actually in the locomotion example script that UMA comes with, I just changed it to derive from NetworkBehavoiur, and added the other networking components mentioned above, and modified the locomotion script thus:
Here is my code:
using UnityEngine;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine.Networking;
public class Locomotion : NetworkBehaviour {
.....
void Start()
{
....
setLayerWeightServer(0, 0); // client call set animation layer weight
}
public void setLayerWeightServer(int layer, float weight)
{
animator.SetLayerWeight(layer, weight);
CmdSetLayerWeightClients(layer, weight); // call to server WORKS!!
}
[Command]
public void CmdSetLayerWeightClients(int layer, float weight)
{
RpcSetLayerWeightClient(layer, weight); // call to clients FAIL!!!!
}
// NEVER GETS CALLED
[ClientRpc]
public void RpcSetLayerWeightClient(int layer, float weight)
{
animator.SetLayerWeight(layer, weight);
}
Anybody has any idea what is wrong???
Sorry to bump this, i am with this bug. I am now also adding UMA to my multiplayer game with dynamic instantiation, The problem still occurs. Did you resolve your problem?
– wahyuwayalright alright alright! It's working, thank You for that, I'm marking it as an answer, but the movement I'm getting is jittery and unfortunately I've no idea why.. It's less noticeable when slowed down so I could potentially hide it as i'm only using this when time's slow, but that wouldn't really meet the "polish" level I want. Any ideas? If not, thank You anyway for sorting the basics out!
– erikiene