So i am making a survival game with photon, but i need the host player to send Vector 3 positions of many moving gamepbjects, (zombies actually) .Since using photonview for each of them wouldn't be a good idea, i do this -
i have a manager common for all players in room , and the zombies that are moving are a part of a list.
The host player calls the function "sync_ai" sending the position along with their list index to all players.
This function gets called in the void Update().
example -
public List zombies;
void Update(){
for ( int i = 0 ; i < zombies.Count ; i ++ )
GetComponent().RPC("sync_ai",Photontargets.others,i, zombies[i].transform.position);
}
[PunRpc]
void sync_ai ( int a , Vector3 pos ){
zombies[a].transform.position = pos;
}
it seems to work fine, but the movement is not smooth and calling the function every frame seems stupid, is there a better way to do this?
i have a manager common for all players in room , and the zombies that are moving are a part of a list.
The host player calls the function "sync_ai" sending the position along with their list index to all players.
This function gets called in the void Update().
example -
public List zombies;
void Update(){
for ( int i = 0 ; i < zombies.Count ; i ++ )
GetComponent().RPC("sync_ai",Photontargets.others,i, zombies[i].transform.position);
}
[PunRpc]
void sync_ai ( int a , Vector3 pos ){
zombies[a].transform.position = pos;
}
it seems to work fine, but the movement is not smooth and calling the function every frame seems stupid, is there a better way to do this?