Search Unity

How to sync particle systems across all clients using Unet?

Discussion in 'UNet' started by mattdavidson2017, May 30, 2019.

  1. mattdavidson2017

    mattdavidson2017

    Joined:
    Apr 12, 2018
    Posts:
    1
    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?

    Code (CSharp):
    1. [Command]
    2.     public void CmdAfterEffects(Vector3 position)
    3.     {
    4.         RpcAfterEffects(position);
    5.     }
    6.    
    7.     [ClientRpc]
    8.     private void RpcAfterEffects(Vector3 position)
    9.     {
    10.         AfterEffects(position);
    11.     }
    12.    
    13.     private void AfterEffects(Vector3 position)
    14.     {
    15.         ParticleSystem cloudParticle = Instantiate(GameManager.instance.GetProjectileManager().cloudParticlePrefab);
    16.         ParticleSystem burstParticle = Instantiate(GameManager.instance.GetProjectileManager().burstParticlePrefab);
    17.         cloudParticle.transform.position = position;
    18.         burstParticle.transform.position = position;
    19.         var cloudSettings = cloudParticle.main;
    20.         cloudSettings.startColor = color;
    21.         var burstSettings = burstParticle.main;
    22.         burstSettings.startColor = color;
    23.        
    24.         cloudParticle.Play();
    25.         burstParticle.Play();
    26.     }
     
  2. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    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.
     
    mattdavidson2017 likes this.