Question by
Ornez · May 01, 2017 at 06:13 PM ·
networkingnetworkchat
Problem with networking/ Command/ ClientRPC/ multiplayerChat.
Hello. When i send message from host, everything works perfect. Everybody can see this message. When i try to send message from client, only client can see it. What should i change? This is my script: using UnityEngine; using UnityEngine.UI; using UnityEngine.Networking;
public class Chat : NetworkBehaviour {
public InputField inputFieldChat;
public string ChatText = "";
public Text txt;
void Start() {
txt = GameObject.Find ("Text").GetComponent<Text> ();
inputFieldChat = GameObject.Find ("InputField").GetComponent<InputField>();
inputFieldChat.onEndEdit.AddListener(delegate {DlaInputu(inputFieldChat.text); });
}
void Update() {
if (!isLocalPlayer)
return;
txt.text = ChatText;
}
public void DlaInputu(string text) {
if (isServer) {
RpcSendMs (text);
}
else if (isLocalPlayer) {
CmdSendMessage (text);
}
}
[Command]
public void CmdSendMessage(string text) {
RpcSendMs (text);
}
[ClientRpc]
public void RpcSendMs(string text) {
Debug.Log ("Got this message " + text);
ChatText += text + "\r\n";
}
} And some screens: Host's ChatText is "Host", Client1's ChatText is"HostP1" and Client2's ChatText is"HostP2" Why when i call [command] it dont call [ClientRPC] like i do when im host :C? I was looking on forums/ tutorials but cant find answer for my problem.
Comment
Your answer
Follow this Question
Related Questions
Chat 5.5 synclist Stuck 1 Answer
local scale network 0 Answers
NullReferenceException at adding a NetworkTransformChild component 1 Answer
What does this error mean? 1 Answer