- Home /
Why the particle system don't play?
I use a particle system named "MuzzleFlash" but when i click the mouse left button it doesn't play at all here is the script i am using:
var MuzzleFlash : boolean;
function Update () {
if(Input.GetButtonDown("Fire1")) { MuzzleFlash = true; } if(Input.GetButtonUp("Fire1")) { MuzzleFlash = false; } }
any help would be very appreciated:)
Answer by efeguclu · Jul 04, 2017 at 12:44 PM
you defined MuzzleFlash as boolean
You could use something like that :
public var MuzzleFlash : ParticleSystem;
//set this in Inspector
if(Input.GetButtonDown("Fire1"))
{
MuzzleFlash.Play();
}
if not try this :
public var MuzzleFlash : ParticleSystem;
var GeneratedPosition;
function Start(){
var x=0;var y=0;var z=0;
x = Random.Range (0.1, 2.9);
y = 10;
z = Random.Range (0.1, 1.9);
GeneratedPosition = new Vector3 (x, y, z);
}
function Update(){
if(Input.GetMouseButtonDown(0))
{
Instantiate(MuzzleFlash, GeneratedPosition,Quaternion.identity);
}
}
i named my fire effect is $$anonymous$$uzzleFlash but when i attached the the script and put my $$anonymous$$uzzleFlash inside then i press left click it is not working
Try this out :
public var $$anonymous$$uzzleFlash : ParticleSystem;
var GeneratedPosition;
function Start(){
var x=0;var y=0;var z=0;
x = Random.Range (0.1, 2.9);
y = 10;
z = Random.Range (0.1, 1.9);
GeneratedPosition = new Vector3 (x, y, z);
}
function Update(){
if(Input.Get$$anonymous$$ouseButtonDown(0))
{
Instantiate($$anonymous$$uzzleFlash, GeneratedPosition,Quaternion.identity);
}
}
Your answer
Follow this Question
Related Questions
Raycast Decals,Sound and MuzzleFlash not working too well 0 Answers
muzzle flash and particle emit didn't show when shot 1 Answer
Disabling Simulate in WorldSpace in Ellipsoid Particle Emitter not working! 0 Answers
Gun Muzzle Flash 2 Answers
Muzzle Flash turning on and off even when not firing 1 Answer