- Home /
Help for muzzle flash script
Hi, i'm not good at scripting so i was thinking about if anyone could write a script too me so i can have two muzzle flashes with (one) gun, because my model have dual wielded pistols so i need two muzzle flashes.
I have seen that people have used particles and prefabs to make some muzzle flashes on this (forum) but I haven't got them to work.
Thanks in advance :)
This isn't where you come to ask someone to write scripts for you. If you're having specific questions about the examples you're trying, by all means ask away.
Answer by save · Jun 16, 2011 at 10:13 PM
I do agree with the statement of CrhisD but thought I'd try to give you a push in the right direction. Basically you create a Particle System and set the emitter options to your liking, preferably add some random velocity so it never looks the same and set it to One Shot and Autodestruct. Make a prefab out of it and then via script instantiate:
var muzzleFlash : ParticleEmitter; //Your emitter prefab
var gunEnd : Transform; //An empty gameobject positioned at the end of the gun as a child
var gunEnd2 : Transform; //Same as above but the other one
//Call OnShooting() from somewhere in your firing script
function OnShooting () {
Instantiate(muzzleFlash, gunEnd.position, gunEnd.rotation);
yield WaitForSeconds (0.2);
Instantiate(muzzleFlash, gunEnd2.position, gunEnd2.rotation);
}
Just a very basic example. Perhaps a switch and a more precise timer in between shots later on would be a good idea. Inside the function you can call for sounds, light and so forth. Hopefully this can get you started though.
Your answer
Follow this Question
Related Questions
Jump. Script. 1 Answer
Jump help! 1 Answer
how do you switch guns from single shot to full auto? 2 Answers
please help weapon sparks 1 Answer
Shoot. Just Shoot 5 Answers