- Home /
Question by
Tathorpe89 · Dec 17, 2016 at 10:57 AM ·
c#networkingvariablessynchronization
Variables not sync'd to clients
public GameObject minionPrefab;
public Transform minionSpawn;
public int myTeam;
public int enemyTeam;
public List<Vector3> teamWaypoints;
void Start () {
InvokeRepeating("SpawnMinions",1,5);
}
void SpawnMinions()
{
teamWaypoints.Add(GameObject.Find("Cube1").transform.position);
teamWaypoints.Add(GameObject.Find("Cube2").transform.position);
teamWaypoints.Add(GameObject.Find("Cube3").transform.position);
teamWaypoints.Add(GameObject.Find("Cube4").transform.position);
var newMinion = (GameObject)Instantiate(minionPrefab, minionSpawn.position, minionSpawn.rotation);
newMinion.GetComponent<MinionNavigation>().myTeam = myTeam;
newMinion.GetComponent<MinionNavigation>().enemyTeam = enemyTeam;
newMinion.GetComponent<MinionNavigation>().waypoints = teamWaypoints;
NetworkServer.Spawn(newMinion);
}
This only spawns my minion prefab with the correct variables on the master client. The rest of the minions get null values.
This is confusing me because I am setting them before the NetworkServer.Spawn call. Are they not being set on the master client before they are cloned to the rest of the clients?
Comment
Your answer
Follow this Question
Related Questions
ScriptableObjects and SyncVars, is it posible? 1 Answer
How to get transform syncing over network to work? 1 Answer
SyncVar issue 0 Answers
UNET: Client Host syncing problems 0 Answers
Networking Sync SetActive Not Working 0 Answers