- Home /
how to synchronize other player actions in multiplayer environment using photon multiplayer ?
hi M developing multiplayer photon networking game I cant see other player action in photon multiplayer, means if other player shooting towards me i cant see he is shooting . I can see just player on network please help me
Thank you...!
Can you share your current code? This helps a lot when trying to figure out what the problem is.
Answer by Boaike · Sep 12, 2015 at 09:19 PM
@ajaybhojani Ok, if you don't see anything the other player is doing, the script you provided is not the right one. You need to have a script with the following in it:
void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
{
if (stream.isWriting)
{
// We own this player: send the others our data
stream.SendNext(transform.position); //position of the character
stream.SendNext(transform.rotation); //rotation of the character
}
else
{
// Network player, receive data
Vector3 syncPosition = (Vector3)stream.ReceiveNext();
Quaternion syncRotation = (Quaternion)stream.ReceiveNext();
}
}
The idea is that you send data if the script is on an object/character that you own, and receive from all other objects (with the same script), so you know where they are (and can animate those objects accordingly with the SyncPosition/SyncRotation information).
What helped me a lot was doing the Marco Polo tutorial. It might be a little old by now, but you can still take a look at it here: https://doc.photonengine.com/en/pun/current/tutorials/tutorial-marco-polo
Answer by ajaybhojani · Sep 14, 2015 at 11:55 AM
thank you very much i was looking for this. its really useful..