- Home /
How to create a muzzle flash particle using legacy particles?
Basicaly what the questions says.
I wanna place particle prefab in front of my weapon barrel to simulate muzzle flash when I shoot and I have a texture for it ,but I dont know how to make that particle ,actually I dont even know where to start (when it comes to MUZZLEFLASH particle prefab)
Please help if you can.
You need to explain more. Are you trying to use a ParticleSystem to shoot multiple particles at the barrel end, or do you want a single image that flashes on and off, or...? What does your firing code look like now?
No its not for shooting particles , its a Raycast shooting script for pistol so I want particle to show muzzle flash once every time when I press fire button and possibly rotate randomly.
But I dont need script ,I just need to know how to make particle prefab for muzzle flash based on particle emitter.
Answer by Grizzly · Aug 17, 2014 at 01:50 AM
Well after some time of testing and trying legacy shaders I managed to solve my problem on my own with legacy shaders indeed and gain new knowlage about this. Basicaly best way to do muzzle flash is by using legacy shaders imo ,easier to modify in this case ,problem is solved.
Answer by Nick4 · Aug 16, 2014 at 08:38 PM
Ok I'll write you through.
Create a particle system and set its startLifetime to 0.2 and adjust the start size as you like. Next, make sure looping is turned off and max particles is set to 1. Go over to emission tab and set rate to 0 and add a burst set time to 0 and particles to 1. Then go over to shape and make sure radius is at least 0.01 and now it's time for the renderer. Before we start doing stuff under the renderer tab, let's create a material first. Right click somewhere on your projects window and select Create > Material and name your material, let's say it's MuzzleMat. Select muzzlemat and attach your muzzle texture to this material. Then you need to select a particle shader. I'd recommend additive shader for a muzzle effect. Select Particles > Additive as your shader. You can also experiment with other particle shaders and see what you can come up with. Now back to our particle system. Go over to renderer tab and attach muzzlemat to material section. Deselect cast shadows and receive shadows options. BAM! There you have your muzzle effect. I haven't actually tried this but I'm sure it'll work just as you expect if you tweak the settings a bit to make it more realistic and pleasing to eye.
It's a little long but it's worth reading if you're new to particle system in Unity. Sorry if I missed anything because I'm not at home at the moment so I can't really test it myself. Good luck
Well it's because it's only one shot. If you want to use it on a automatic weapon then you'd need to use "rate" under the emission tab ins$$anonymous$$d of 1 burst. You can also pool all the one shot muzzle fx and light it up each shot and disable it when you're done this way it won't take up much processing power. And I'm not sure about the other particle system, I never used it. If you meant that it's off the center sometimes, make sure to set your shape to sphere and radius to at least 0.01.
For more realism on muzzle flashes, make them bigger and brighter. Here's an extra tip, $$anonymous$$ake start rotation "random between 2 constants and give them 0, 180 values in order to make the muzzle flash look different each time it's shot.
You have to use :
objectWithParticleSystem.particleSystem.enableEmission = false
to disable emission.
It's your game object that has particle system component. But if you attach that emission disabling script to your particle system gameobject you don't need that reference. You can just write
particleSystem.enableEmission = false;
In your case, you can use $$anonymous$$uzzleFlash variable to disable emission.
$$anonymous$$uzzleFlash.enableEmission = false;
Your answer

Follow this Question
Related Questions
Where to put Particle Emitter? 0 Answers
I have a particle system but I can't access it's particle emitter 1 Answer
add delay to multiple particle emitters 0 Answers
Ink-like particle effect 1 Answer