- Home /
Question by
JollyCoke · May 12, 2016 at 06:00 PM ·
multiplayerspawnspawning
Object not spawned on future clients
Hi. I have a script, that spawns an object from the Start method, which is run when the player joins the server. The problem I have, is that when player 2 joins, the object that player 1 spawned, doesnt get spawned for player 2. This is my code:
void Start()
{
if (isLocalPlayer)
{
CmdSpawn();
}
}
[Command]
public void CmdSpawn()
{
GameObject go = (GameObject)Instantiate(hookPrefab, transform.position, transform.rotation);
NetworkServer.SpawnWithClientAuthority(go, gameObject);
RpcSetHook(go);
}
[ClientRpc]
void RpcSetHook(GameObject go)
{
hook = go;
}
Comment
Your answer
Follow this Question
Related Questions
Network spawning 1 Answer
NPCs falling through terrain 1 Answer
Having Trouble with Instantiating an object on an axis 2 Answers
Creating a random number of spawning items on collision 2 Answers
Unet spawn a camera? 0 Answers