How to/ Best Way to broadcast previously instantiated sceneobjects to new clients?
Options
Hi, I'll get right to it.
Spawning NPC's to scene like this-
PhotonNetwork.InstantiateSceneObject(MyPrefab, pos, Quaternion.identity, 0, null);
This works fine so long as the clients are in game when the object is instantiated.
New clients do not see them : (
How to solve this..
It seems the most efficient time to do it would be on player login, something like-
void MobInfo()
if (PhotonNetwork.isMine)
{
photonView.RPC("RequestActiveMobs", PhotonTargets.MasterClient, PhotonNetwork.player, 0, name);
}
[PunRPC]
public void RequestActiveMobs()
{
if (photonview.isMasterClient)
{
GameObject[] mobs = FindObjectsWithTag("NPC");
if (mobs != null)}
(some type of FOR loop building an array that can be sent to new client)};
}
}
void OnJoinedRoom(){
MasterClient.MobInfo();
}
Of course this isn't working code, but you see what I'm asking right?
Please... show me some very simple function that updates late clients without going down this road: )
ps. First post!
Spawning NPC's to scene like this-
PhotonNetwork.InstantiateSceneObject(MyPrefab, pos, Quaternion.identity, 0, null);
This works fine so long as the clients are in game when the object is instantiated.
New clients do not see them : (
How to solve this..
It seems the most efficient time to do it would be on player login, something like-
void MobInfo()
if (PhotonNetwork.isMine)
{
photonView.RPC("RequestActiveMobs", PhotonTargets.MasterClient, PhotonNetwork.player, 0, name);
}
[PunRPC]
public void RequestActiveMobs()
{
if (photonview.isMasterClient)
{
GameObject[] mobs = FindObjectsWithTag("NPC");
if (mobs != null)}
(some type of FOR loop building an array that can be sent to new client)};
}
}
void OnJoinedRoom(){
MasterClient.MobInfo();
}
Of course this isn't working code, but you see what I'm asking right?
Please... show me some very simple function that updates late clients without going down this road: )
ps. First post!
0
Comments
-
OR, could it even be so simple as
Photonview myView;
myView = MasterClient.PhotonView;
0 -
OK looking at This thread here, it seems this may be my answer, as well..
http://forum.photonengine.com/discussion/3052/photon-instantiate-not-refreshing-for-recently-joined-player0 -
*SOLVED*
Add "Do Not Destroy on Load" scripts to the prefab NPC objects in Resources.0