Spawning Enemy
Hello , i have a question about instantiate with Photon :
I want to make a spawning system .
How can i instantiate a prefab and see this prefab for all client ( Master too ) ?
public void OnJoinedRoom()
{
if (PhotonNetwork.isMasterClient)
{
// Enemy is a prefab in the '' Ressources '' folder , and this prefab have a '' photon view '' .
PhotonNetwork.Instantiate("Enemy", new Vector3(0, 0, 0), Quaternion.identity, 0);
}
}
When i do that i instantiate the prefab correctly but there is only the masterclient who can see the prefab ... why ? i want all Clients able to see this prefab ....
Thanks in advance for you response .
I want to make a spawning system .
How can i instantiate a prefab and see this prefab for all client ( Master too ) ?
public void OnJoinedRoom()
{
if (PhotonNetwork.isMasterClient)
{
// Enemy is a prefab in the '' Ressources '' folder , and this prefab have a '' photon view '' .
PhotonNetwork.Instantiate("Enemy", new Vector3(0, 0, 0), Quaternion.identity, 0);
}
}
When i do that i instantiate the prefab correctly but there is only the masterclient who can see the prefab ... why ? i want all Clients able to see this prefab ....
Thanks in advance for you response .
0
Comments
-
anyone ?0
-
Hi @DarnightDEV,
basically you are doing things already right, at least I don't see any problems with the code snippet above. Can you confirm that all your clients are in the same room and run the 'same' game including all assets?0 -
Hi @Christian_Simon ,
Thanks for the response , but I misspoke about something . I instantiate correctly this prefab and all client can see the prefab but the problem is : this prefab have a script which allows him to move ( IA system ) and when this prefab move , nobody see the movement of this prefab ( except the masterclient )
Do you have a solution ?
Thanks in advance,0 -
I guess you don't synchronize the movement, so nobody else except the MasterClient can see this. An easy solution here is to attach a PhotonTransformView component to the prefab and add it to the PhotonView's observed components list.0