- Home /
Particles Energy vs Emissions
Hello, I'm a bit new to unity so I apologize in advance if this is basic. I'm creating a particle system to simulate the flash from a machine gun. I simply want to flash one particle very briefly at a regular rate. Additionally I want to control the rate of flash to match the rate of my machine gun. Pretty simple and I have it all setup. What I'm noticing, however, is that when I crank the min and max energy level fairly low (0.01) I have to crank my Min and Max emission level way up to any speed out of it. I was expecting the emission level to not depend on the energy level unless I surpass some max number of particles. But since my energy is so low, I really only want one particle at a time, which I'm getting. The question is more around the particle system as I understand several ways of doing the actual muzzle flash.
Any help would be greatly appreciated.
Answer by Tuti · Dec 01, 2010 at 04:30 AM
I wouldn't use a particle system to show a muzzle flash. Instead I'd use a mesh renderer which would have a shape, texture and properly shader applied like particles additive.
Take a look here at the FPS tutorial as it is a powerful tool to beginners.
I took the section where it enables and disables the muzzle flash. Page 13 of tutorial #2:
function LateUpdate()
{
if (muzzleFlash)
{
// We shot this frame, enable the muzzle flash
if (m_LastFrameShot == Time.frameCount)
{
muzzleFlash.transform.localRotation =
Quaternion.AngleAxis(Random.Range(0, 359), Vector3.forward);
muzzleFlash.enabled = true;
if (audio)
{
if (!audio.isPlaying)
audio.Play();
audio.loop = true;
}
}
// We didn't, disable the muzzle flash
else
{
muzzleFlash.enabled = false;
enabled = false;
// Play sound
if (audio)
{
audio.loop = false;
}
}
}
Notice that it controls when the muzzle flash will be rendered by memorizing the frame number of the last shot, then it will show only for one frame and then will be disabled.
I hope that helps.
Awesome. I may use that. Though I have smoke and tracers to deal with as well. But I can see how I may do that. $$anonymous$$y question, however, was more related to the particle system behaviour and the relationship between energy and emission. I was not real clear on that.
Energy is how long your particle will last, the less the value, the less the particle will last. Emission is how many copies of the particle the engine will make, the higher the number, more and more particles you will see be emmited.
I feel that I understand that. What I'm seeing is that lowering the energy is effecting the emission and I'm trying to deter$$anonymous$$e why such that I can construct a system that has very few particles and I can adjust the emission in a predictable way. What I am, seeing is that with an energy of .01, I have to crank up the emissions to somewhere in the hundreds to get any more the 1 or 2 particles per second showing up in the animation. The docs claim that emissions is particles per second, but with low energies it apparently is not. Why?
I beg to differ, my particle-system-based muzzle flash looks amazing, and is pretty simple. It's basically a tweaked version of an explosion from the detonator framework that emits with random local rotations and emissions(within a range) through script, and looks pretty sweet.
Answer by femi · Jan 04, 2011 at 03:10 PM
Energy of 0.01 corresponds to particle life span of 10 ms.
The infamous 25th frame lasted for 40 ms and people claimed not to have seen it. 10 ms would be 4 times as subliminal.
With display refresh rate of, say, 50Hz you only get to see a new picture every 20ms. With sync to vblank turned off your graphics card can render faster then the monitor can display and of each of the frames rendered only a part will be actually visible (some of the particles might end up on those rendered but not shown parts of the frame).
Finally, many of your particles will just die between rendered / shown frames. By increasing the emission you increase the probability that some of the particles will be rendered (will be still alive by the time rendering happens).
Your answer
Follow this Question
Related Questions
Making gun fire particle 2 Answers
MuzzleFlash for gun 0 Answers
Bootcamp destroy a Enemy 2 Answers
Rotate the textures in the particle system to direction of the particle system? 1 Answer
Gun Muzzle Flash Effect 0 Answers