So I’ve been having an issue trying to figure this out, but I want to set variables for individual players in the game, referring to networking UNET. I’ve been trying to get familiar with it, and I get a few things but get lost on a lot more. I’m aiming to give all clients a variable, but each client has a different value based on it’s choice. Example would be, all clients have a string startingWeapon, one client could have a sword while another has a dagger. How would I go about transferring that data? Here was my attempt to sync client variables:
[SyncVar (hook = "onLoad")]
public int x = 0;
void Update()
{
if (hasAuthority)
{ CmdChangeValue(PlayerPrefs.GetInt("customizedHead", 0)); }
}
void onLoad(int n)
{
Debug.Log("value was changed: " + n);
}
[Command]
void CmdChangeValue(int value)
{
x = value;
}
This code makes it to where whoever holds the server overpowers all clients with it’s variable. So if the host had a value of 3, all clients have a value of 3, which is not what I’m aiming for. I’d like each client to have it’s own value, but synchronized across the game. I’m trying to word this the best I can, lol, it’s hard for me to describe networking, but am I on the right track with what I want to do? Cause, honestly, I have no idea.
EDIT: okay now the code is half working, through the standalone it works, but through the editor, it doesn’t. Ugh I’m so lost