So from the manual I was under the impression that NetworkServer.Spawn() would spawn the GameObject at the same position and rotation that I instantiated it at. However what I am seeing is that NetworkServer.Spawn() is sending all the objects to 0,0,0. Despite the fact that I am instantiating the objects at custom positions, shown in this code below:
public override void OnStartServer()
{
base.OnStartServer();
cards = GenerateDeckInitial();
}
public override void OnStartClient()
{
Debug.Log("Cards CLIENT: " + cards.Count());
}
public SyncList<GameObject> GenerateDeckInitial() {
SyncList<GameObject> cardsList = new SyncList<GameObject>();
GameObject parentPosition = GameObject.Find("parentActions");
foreach (var prefab in PrefabsActionCards)
{
Type ScriptCard = Type.GetType(prefab.name + ",Assembly-CSharp");
var script = prefab.GetComponent(ScriptCard);
var quantidade = (int)script.GetType().GetField("Quantidade").GetValue(script);
for (int j = 0; j < quantidade; j++)
{
GameObject card = Instantiate(prefab, gameObject.transform.position ,gameObject.transform.rotation, gameObject.transform);
NetworkServer.Spawn(card);
card.name = prefab.name.Replace("(Clone)", "");
cardsList.Add(card);
}
}
//ShuffleList(cardsList);
//OrganizeCardHierarchy(cardsList, parentPosition, gameObject);
return cardsList;
}
This happening only client-side, in host player it’s correct!!
What is wrong?