Question by
Chom1czek · Oct 20, 2015 at 11:42 AM ·
networkinginstantiaterpccommand
Instantiating over the Network, good way?
Hello, I just wanted to ask if it's good way to instantiate an object on a local player that needs also to be seen by other players across the Network? It works but I want to know if it's correct way or is there any cleaner sollution :)
private void Update()
{
if(Input.GetKeyDown(KeyCode.F))
{
if(isLocalPlayer)
{
CmdCreateObj();
}
}
}
[Command]
void CmdCreateObj()
{
RpcCreateAcross();
}
[ClientRpc]
void RpcCreateAcross()
{
GameObject obj = Instantiate(instantiating stuff);
}
Comment
Answer by rajavamsidhar_gvs · Oct 26, 2015 at 07:21 AM
hi..as of my knowledge we can send int,float,string,networkplayer,networkmessages through in rpc's. better to use NetworkServer.Spawn(). it can help you.
GameObject obj = GameObject.Instantiate(prefab); // server-side copy
NetworkServer.Spawn(obj); // send spawn message to clients
and once see this link it can help you.
Your answer
Follow this Question
Related Questions
Photon RPC 2 Answers
Question to RPC and Command (Unet) 0 Answers
ClientRpc/Commands between two seperate projects? 0 Answers