- Home /
Gun Muzzle Flash
I know there's a lot of questions about this topic but ive tied nearly all of them and non have worked. Can anyone tell me how I could make a muzzle flash occur whenever the player presses the left mouse button? Ive heard that you make a plane and add a muzzle flash texture onto which I have done but I don't know how to code it.
This doesnt mean they dont work, it means you still have to learn how to script; step back and complete these websites and then i'm sure you'll be able todo it; www.unity3dstudent.com
Answer by Owen-Reynolds · Oct 08, 2011 at 04:32 PM
Unity doesn't support the standard 2 billboard solution as well -- you could write it custom using a LineRender and a plane. But, a standard particle effect can make a nice one, if you know the settings (I'm skipping soem of the obvious ones, like Size):
Shrink the Ellipsoid (where they spawn from,) set OneShot and Autodestruct. Set localVelocity z to 5 or so and random x/y/z to about 3 (setting z to 3 will make the real z velocity random 2-8.) Set min/max life to around 0.1 or less (1/10th sec is 6 frames.) Go down and set StretchParticles to Stretch and LengthScale to negative (it stretches particles backwards along the way they are moving, to give a trail. Flipping to neg makes the particles stretch forwards.) Should get a quick cone.
To get it more jaggy (this is the part everyone using Emitters really need to know) make your own particle material: create a texture with a flatish bottom and jaggy top (like grass.) Put in a material, set the shader to Particles/AlphaBlended (or try the other ones near it.) Swap the material into your Emitter (replaces DefaultParticle.)
When you say $$anonymous$$/max life do you mean $$anonymous$$/max emission? because there isn't a setting called $$anonymous$$/max life.
I have done all of that but how would I script it so it only shows when the left mouse button has been clicked?
I assume you are spawning a bullet Prefab, using Instantiate from an empty at the end of the gun. Do it again for the "flash" Particle Emitter.
How do I change the time the particle effect lasts for? Please help
Answer by beattonick · Oct 03, 2011 at 11:46 PM
you can do the fps turorial from unity they cover how to use muzzle flashes
The fps tutorial's muzzle flash tutorial script is mostly for damage and reloading for the rest of the guns functions which I do not want and the muzzle flash itself dosent work anyway.
Your answer
Follow this Question
Related Questions
how to make gunshots 0 Answers
FPS PISTOL 1 Answer
A node in a childnode? 1 Answer
Mouse look alteration? 1 Answer
The name 'Joystick' does not denote a valid type ('not found') 2 Answers