Network Chat System Help
Hello, I have an issue with networking. I am still learning things and Im trying to make a chat box. Its pretty simple, locally.
I have a canvas for the local player which has chat box. I instantiate a text gameobject (prefab) and parent it to the chat box, and change the text to what was input by the player.
It works fine locally, but its supposed to create a new chat box text entry on every players chat box, but it only works locally. This sctipt uses network behavior and is attached to the player. I was able to get an item to destroy across the server, but this wont work for me..
/* ServerSide ADD TEXT TO CHATBOX: Player Chat */
public void SendNewMessage(string message)
{
// Create a new Text Object Prefab
GameObject newText = Instantiate(chatBoxText);
// parent it to a local canvas's chat box
newText.transform.SetParent(GetComponent<PlayerControl>().chatBoxContent.transform);
// set the text to the inputed text
newText.GetComponent<Text>().text = message;
}
[Command]
public void CmdAddTextToChatBox_PlayerInput(string message)
{
RpcAddTextToChatBox_PlayerInput(message);
}
[ClientRpc]
public void RpcAddTextToChatBox_PlayerInput(string message)
{
SendNewMessage(message);
}
public void AddTextToChatBox_PlayerInput()
{
CmdAddTextToChatBox_PlayerInput(playerInputFieldText.text);
}
Your answer
Follow this Question
Related Questions
Android server side programming language? 0 Answers
Unity Network Spawning Prefabs 0 Answers
NetworkAnimator leaks memory 0 Answers
How do I pass a int value from one class to another with RPC? 0 Answers
Photon not working/detected 2 Answers