RPC Broadcast using Unet

Hi, i need help with my multiplayer game using Unet, i have a script which creates a chat gui, when i press enter the text gets send to the server using [Command] but how do i send the text to all player instances ? . When i use syncvar or rpc only the original player instance will get the text.

sincerly frubi

Can you share your current code of that command and some info on your setup? Your project can be anything.

With that little info I can only tell you that you need a ClientRPC method that your server should call after executing the command. Something like:

[Client]
public void SendMessage(string msg) {
    CmdSendMessage(msg);
}

[Command]
void CmdSendMessage(string msg){
    chat.AddMessage(msg);
    RpcAddMessage(msg);
}

[ClientRpc]
void RpcAddMessage(string msg) {
    chat.AddMessage(msg);
}

Also, I noted you said “the player that sent the text”… are you talking about the player (you’ll have multiple players for each client, one being the local player) or the client? If you’re expecting the SyncVar off all players being updated or the Rpc method of all players being called you’re missunderstanding some concepts. The ClientRpc runs on a certain player (the “same” player) in all the clients. Also, make sure you’re using ClientRpc and not the new TargetRpc, which actually runs only on one player of the target client.