Object Spawning in Multiplayer

Updated on April 4, 2016 in [A] Multiplayer
Share on Facebook0Tweet about this on TwitterShare on Google+0Share on Reddit0
4 on March 24, 2016

What is the best way of spawning objects?
or what is the big difference?
1: Like in Brackeys tuturials (with a client, command and a clientRpc);

 [Client]
 void Shoot()
 {
 if (!isLocalPlayer)
 return;
 CmdOnShoot();
 }
 [Command]
 void CmdOnShoot()
 {
 RpcShootEffect();
 }
 [ClientRpc]
 void RpcShootEffect()
 {
 GameObject thing = (GameObject)Instantiate(Obj);
 }
 

or
2: With this (using NetworkServer.Spawn(Obj));
 public void Spawn()
 {
 GameObject thing = (GameObject)Instantiate(Obj);
 NetworkServer.Spawn(thing);
 }
 

And the last question,
How can I make it that if somebody who is later in the game, still sees the instantiated things?
(for example: A building game, I’m building my house and having fun playing with my friends, than later an other friend joins the game, but he doesn’t see any thing we have build so far.
+ he can even build on the places we have build because for him there are no buildings there.)

sorry for bad English.

  • Liked by
Reply
1 on March 24, 2016
Wise
on March 29, 2016

I know, but I have found it already.
But tnx.

Show more replies
  • Liked by
Reply
Cancel
1 on April 2, 2016

I have no idea, but with Photon there is a way to keep instantiated objects for people who joins later.

Wise
on April 4, 2016

I know, but I already found it.
You have to register the objects to the network, and than network spawn.

Show more replies
  • Liked by
Reply
Cancel