How to sync particle systems across all clients using Unet?

Hi,
So the code below is my current code and my goal is that when a bullet hits a collider it should be destroyed and two different particle systems should play on all of the clients. However, when the code below is executed, the particle systems only play on the local client. Is there any way to fix this?

[Command]
    public void CmdAfterEffects(Vector3 position)
    {
        RpcAfterEffects(position);
    }
   
    [ClientRpc]
    private void RpcAfterEffects(Vector3 position)
    {
        AfterEffects(position);
    }
   
    private void AfterEffects(Vector3 position)
    {
        ParticleSystem cloudParticle = Instantiate(GameManager.instance.GetProjectileManager().cloudParticlePrefab);
        ParticleSystem burstParticle = Instantiate(GameManager.instance.GetProjectileManager().burstParticlePrefab);
        cloudParticle.transform.position = position;
        burstParticle.transform.position = position;
        var cloudSettings = cloudParticle.main;
        cloudSettings.startColor = color;
        var burstSettings = burstParticle.main;
        burstSettings.startColor = color;
       
        cloudParticle.Play();
        burstParticle.Play();
    }

Have you verified the server has run the Command? Put Debug.Log messages everywhere to verify the server runs the Command and the clients run the ClientRpc. Then you’ll know if there is some problem with your network code, or some issue with the actual particle system spawning.

Check your console/log output for warnings or errors related to trying to run a command without authority, etc.

1 Like