- Home /
Particle System doesn't want to Play
I will try to provide as much detail as I can to help you help me: I have this particle System:
It is a prefab so I have to instantiate it first to be able to play it. So here is the code:
public ParticleSystem[] muzzie;
public void BuyAk()
{
CmdSpawnThatWeapon(0);
}
[Command]
void CmdSpawnThatWeapon(int index)
{
RpcSpawnThatWeapon(index);
}
[ClientRpc]
void RpcSpawnThatWeapon(int index)
{
muzzie[index] = Instantiate(_weapon.weaponProperties[index].muzzleFlash, _weapon.weaponProperties[index].Firepoint.transform.position, _weapon.weaponProperties[index].Firepoint.transform.rotation, _weapon.weaponProperties[index].Firepoint.transform);
The muzzle flash is spawned and i can make sure of its presence in the inspector as i made the muzzle flash array public.
Here is the code from the shooting script:
void Shoot(){
RaycastHit _hit;
if (Physics.Raycast(cam.transform.position, cam.transform.forward, out _hit,_range, mask))
{
if(_hit.collider.tag == PLAYERTAG && _psgame.isPaused)
{
CmdPlayerShot(_hit.collider.name, _damage);
}
}
}
[Command]
void CmdOnShoot(int index1)
{
RpcDoMuzzleFlash(index1);
}
[ClientRpc]
void RpcDoMuzzleFlash(int index2)
{
_shop.muzzie[index2].Play();
Debug.Log(index2);
}
I have even made a debug.Log to make sure the method is called when I shoot, and indeed it is and also I wanted it to print the index. But the muzzle flash doesn't play. Also when I press play, in the hierarchy, the Particle effect is instantiated and If I press Play in the scene is does Play. Thank you in advance.
Your answer
Follow this Question
Related Questions
How to Instantiate gameObject where a particle dies 2 Answers
Avoid particle system play on instantiate 1 Answer
Play ParticleSystem on RayCastHit Object 1 Answer
Create with Code 4.4 For-Loops For Waves: play mode freeze 0 Answers
How do I make instantiated particles inherit Transform movement from their parent object? 1 Answer