Particle Synchronization Not Working Properly

[PunRPC]
void RPC_ShootParticles(Player owner)
    {
        PhotonView photonView = GetComponent<PhotonView>();

        if (photonView.Owner == owner)
        {
            ParticleSystem muzzleFlash = transform.FindChildRecursive("Fireworks").GetComponent<ParticleSystem>();
            if (muzzleFlash.isPlaying)
            {
                muzzleFlash.Stop();
            }
            muzzleFlash.Play();
        }
}

 void Shoot()
{
        PhotonView photonView = GetComponent<PhotonView>();
        if (photonView)
        {
            if (photonView.IsMine)
            {
                photonView.RPC("RPC_ShootParticles", RpcTarget.All, photonView.Owner);
            }
        }
}

The code above shoots the particle for the shooter on all guns (problem number one), and no other client sees the particles (problem number two). How can I make it that only the shooter's gun shoots, and everyone sees it? Please answer and don't shut the discussion before I respond.

Comments

  • First off: You don't need to send the owner. The object (PhotonView) you target, will be the same on both clients. That's what PhotonViews are for. So the owner is known on any client that gets the RPC.

    This means you can skip the checks in RPC_ShootParticles().
    Before you do anything more complex, just use a Debug.Log() in this place and log that the RPC was called and on which object. Double check it will be called on the same networked object for each player in a room and then get the fireworks working right (which is no longer a networking task then, cause that is done when the RPC gets called on everyone's client).

    Problem number one: You have to call Shoot() only on one networked object. If it's called on all guns of one player, this is not a networking issue. PUN does not call Shoot().

  • @Tobias I was told to send the owner by a mod in another forum. He didn't explain, and he closed the forum without letting me reply.

    How would I make sure RPC_ShootParticles() is only called by the shooter, if it's not?
  • I don't know how to answer that.
    You have to figure out which game object should shoot the particles. The RPC is only there to sync that.