- Home /
Question by
Dimilicious · Dec 08, 2015 at 11:57 AM ·
unity 5networking
UNET. Objects are spawning not properly on the Client
I'm trying to spawn objects and to parent them to another object in the scene. The objects are spawned both on client and host, but the issue is, that parenting is working only on the host.
Setting the parent:
go.transform.SetParent(GameObject.Find("GameCanvas").transform);
The whole code:
public override void OnStartServer()
{
buttonSpawns = GameObject.FindGameObjectsWithTag("ButtonSpawn");
StartSpawn();
}
void StartSpawn()
{
for (int i = 0; i < numberOfButtons; i++)
{
SpawnButtons(buttonSpawns[i].transform.position);
}
}
void SpawnButtons(Vector3 spawnPos)
{
counter++;
GameObject go = GameObject.Instantiate(buttonPrefab, spawnPos, Quaternion.identity) as GameObject;
go.GetComponent<Button_ID>().buttonID = "Button" + counter;
go.transform.SetParent(GameObject.Find("GameCanvas").transform);
NetworkServer.Spawn(go);
}
Comment
Your answer
Follow this Question
Related Questions
How to use NetworkManager.ServerChangeScene ? 1 Answer
Spaw dynamic (unregistered) object on network (UNET) 0 Answers
how do you send commands from objects that dont have "Authortiy" unet 1 Answer
can't switching between weapons in multiplayer game? 0 Answers
Network Transport Layer API does not work with iOS to PC? 1 Answer