I am very new to networking and trying to wrap my head around how to use an RPC to instantiate a player. I am trying to have my server be “Authorative” so I want to have the client send an RPC to the server and have the server instantiate the player prefab.
So - how do I do this?
I see two ways of doing this, not sure which is right:
I could create an RPC on the client which has the instantiate function inside it and send that to the server. But I am not sure if the server would actually take that and call the instantiate command on the client? Confused there. Would be something like this:
void InstantiatePlayer (GameObject playerPrefab, Vector3 spawnLocation, Quaternion spawnRotation, int myGroup)
Network.Instantiate(playerPrefab, spawnLocation, spawnRotation, myGroup);
- I would send a RPC from the client with a bool to the server, and when the server receives it sees that iWantToInsantiateAPlayer is true and it instantiates the player.
Thoughts on how this is done? Thanks.