Hello everyone,
I’m facing a problem with syncing a string, it seems very simple but i’m really stuck … I explain.
I want to have a string sync between all the devices connected together.
exemple : a button with an inputField, when you type something and press button the syncVar string is modified everywhere.
But at this point my problem is, it works when use this on the host, but when i use it on a simple client, only his SyncVar string is modified.
I just don’t get it, SyncVar are not supposed to be sync ? Why does it work only on the host ?
Here is the kind of code i used :
[SyncVar]
public string testString;
void Start()
{
testString = string.Empty;
}
void OnGUI()
{
if (isLocalPlayer)
{
GUI.Box(new Rect(10, 10, 200, 50), ("String : " + testString));
}
}
public void testStringChanged(string yolo)
{
if (isServer)
RpcTestString(yolo);
else
CmdTestString(yolo);
}
[ClientRpc]
void RpcTestString(string yolo)
{
testString = yolo;
}
[Command]
void CmdTestString(string yolo)
{
testString = yolo;
RpcAudioPathp(testString);
}
I am a beginner in networking stuff, if someone can explain the problem, or maybe the right way to do it, it’ll help me a lot.
Thanks ![]()