How am I able to sync particles from my gun with other clients?

Options
First of all sorry for my bad english.


I programmed a multiplayer game with photon in which you can shoot with a gun. With the help of tutorials I was able to sync the tranformation and rotation with the other clients. I also can shoot them, so they can die. My only problem is, that when I shoot with my gun only I can see the partical effects and the impact prefab. Now to my question. Can someone explain what I have to do, to sync the partical effects of my gun with the other clients.




Here is the shooting script of my weapon



//
//
//PLS READ MY COMMENTS

using UnityEngine;
using System.Collections;

public class Shoothing : MonoBehaviour
{

public ParticleSystem muzzleFlash;
public GameObject impactPrefab;

Animator anim;
GameObject[] impacts;
int currentImpact = 0;
int maxImpacts = 5;
bool shooting = false;
float damage = 25;


void Start()
{



impacts = new GameObject[maxImpacts];
for (int i = 0; i < maxImpacts; i++)
impacts[i] = (GameObject)Instantiate(impactPrefab);

anim = GetComponentInChildren();
}


void Update()
{
AudioSource audio = GetComponent();

if (Input.GetButtonDown("Fire1")&& !anim.GetCurrentAnimatorStateInfo(0).IsName("autopistol_walk"))
{
//thats the partical effect
muzzleFlash.Play();
anim.SetTrigger("Fire");
shooting = true;
audio.Play();
}

}

void FixedUpdate()
{
if (shooting)
{
shooting = false;

RaycastHit hit;
if (Physics.Raycast(transform.position, transform.forward, out hit, 200f))
{


//As you can see I already synct the damage with the server and the other clients

if (hit.transform.tag == "Player")

{
hit.transform.GetComponent().RPC("GetShot", PhotonTargets.All, damage, PhotonNetwork.player.name);
}


impacts[currentImpact].transform.position = hit.point;
// thats the impact prefab
impacts[currentImpact].GetComponent().Play();

if (++currentImpact >= maxImpacts)
currentImpact = 0;
}
}
}
}


Best Answers

Answers

  • Pav
    Options
    @Christian_Simon Would you also do Photon.IsMine for health update PunRPC?