- Home /
How to Sync between Clinet->Server? (Mirror)
Hello, So I'm making a 2d survival game, at this point I made Seasons change (Script is running only on Host) within all of the clients and host. But there is a problem with the Variable "Cuted", I want it to be changeable by the Client to! I know that I need to use Command and ClientRpc but I am just too dump for it, when I wanted to do that by this way no one was able to change that. So my question is: How should function that will change SyncVar between Clinet->Server and Server->Client looks?
[SyncVar(hook = nameof(help))]
public bool Winter;
[SyncVar(hook = nameof(help))]
public bool Summer;
[SyncVar(hook = nameof(help))]
public bool Spring;
[SyncVar(hook = nameof(help))]
public bool Autumn;
[SyncVar(hook = nameof(help))]
public bool Cuted;
public Sprite CutedSprite;
public Sprite AutumnSprite;
public Sprite WinterSprite;
public Sprite SpringSprite;
public Sprite SummerSprite;
void Start()
{
help(true, false);
}
public void help(bool jprdlnwmocochodzialemozezadziala, bool ejserionwmcojarobie)
{
if (Cuted == true)
{
this.gameObject.GetComponent<SpriteRenderer>().sprite = CutedSprite;
}
else if (Autumn == true)
{
this.gameObject.GetComponent<SpriteRenderer>().sprite = AutumnSprite;
}
else if (Winter == true)
{
this.gameObject.GetComponent<SpriteRenderer>().sprite = WinterSprite;
}
else if (Spring == true)
{
this.gameObject.GetComponent<SpriteRenderer>().sprite = SpringSprite;
}
else if (Summer == true)
{
this.gameObject.GetComponent<SpriteRenderer>().sprite = SummerSprite;
}
}
Your answer
Follow this Question
Related Questions
Help me understand SyncVars please 0 Answers
Game data sync with server 0 Answers
How do I use uNET to send client data to server (SyncListBool goes the wrong way)? 1 Answer
Server + Client NPC Syncing issue 1 Answer
Unity networking tutorial? 6 Answers