- Home /
Rpc client issue
Hello,
I need your help to make an RPC function work. I have a button in Unity, onClick call this function :
public void LaunchGame() {
if (Network.connections.Length == 1 && Network.isServer) {
Debug.Log ("Game Starting...");
gameControllerGameObject.GetComponent<GameController> ().LaunchingGame ();
} else {
Debug.Log ("You need to host a server with at least two players to start a game");
}
}
On the Gamecontroller script there is those 2 functions.
public void LaunchingGame() {
RpcLaunch ();
}
[ClientRpc]
public void RpcLaunch () {
testObject.GetComponent<Image> ().color = Color.blue;
}
I tried with multiple way, with Command, NetworkIdentity or not on GameController and the Test Object. But I always get this error.
RPC Function RpcLaunch called on client.
UnityEngine.Debug:LogError(Object)
GameController:CallRpcLaunch()
GameController:LaunchingGame() (at Assets/Scripts/GameController.cs:36)
UnityEngine.EventSystems.EventSystem:Update()
I already make a RpcClient function and it was working so I don't understand why this one doesn't work, I'm sure I missed a simple things.
Thank you.
Comment