I want the client to create the object
But ‘NetworkServer.Spawn ();’ it seems only server role
How do I make the client to create was built as a server?
I want the client to create the object
But ‘NetworkServer.Spawn ();’ it seems only server role
How do I make the client to create was built as a server?
Ideally, the server should create the object, then all the other clients will know about it too. The client player could use a Command to tell the server to do this.
[Client] // called only on client
public void SpawnObject(Vector3 location)
{
CmdSpawn(location);
}
[Command] // runs only on server
private void CmdSpawn(Vector3 location)
{
var obj = (GameObject)Instantiate(MyPrefab, location, someRotation);
NetworkServer.Spawn(obj);
}
This assumes that you have NetworkIdentity on your prefab, and that the Player object this is in is a NetworkBehaviour.
If I use a command and inside I call a RpcClient function to instantiate an onbject.
I am using only the Instantiate method and it is working, so why use NetworkServer.Spawn?
Dont got when i have to use it. What is the difference?