views:

116

answers:

3

Hi,

I'm writing a particle system for our student game, and I've run into a bit of a snag. I want to improve the effect on the ships' rockets, but I can't seem to figure out how.

Here's how the effect looks on a stationary ship:

alt text

And here's how it looks on a moving ship:

alt text

I want the flames to be the same length consistently. Here's Particle's Tick function:

void Particle::Tick(float a_DT)
{
    // temporarily turned off to see the effect of the rest of the code more clearly
//m_Pos += m_Vel;

    if (m_Owner) { m_Pos += m_Owner->GetParentSpeed(); }

    m_Life -= 1;

    if (m_Life <= 0) { m_Alive = false; }
}

Thanks in advance.

EDIT: To clear things up a bit, I want the effect to trail, but I want it to trail the same way regardless of the emitter's speed.

A: 

If you want it to have its own length consistently then you'll need to normalize the parent's velocity by dividing it by the parent's speed. Obviously this will not work if the parent is sitting still so you'll need some sort of "idle" state for the particles in that case (random conical distribution or whatnot).

Also, only acquire the velocity in the constructor, and keep using it during the ticks.

Ignacio Vazquez-Abrams
A: 

Are there any random variables in the system? Number of particles per emitter, particle life etc? This would cause the trails to be of varying length.

Shorty
+5  A: 

You're making the particles move faster or slower according to the parent ship's speed, but their lifetime is some constant that you decrement by one until you reach zero, correct?

What you probably want to do is set the lifetime to a distance value, rather than some number of ticks. Then, subtract the ship's speed (or whatever you're adding to each particle on each tick) from the lifetime. When lifetime goes negative, kill the particle.


I think that's what you want... but it might be cooler (and more realistic) if you make two changes to your algorithm:

  1. The current behavior (length of the tail) is correct if the particle speed coming out of your engines is based upon thrust (acceleration rather than just speed).

  2. Once a particle leaves the engine, any changes in speed/direction of the ship have no effect on it. Once the particle is emitted, it's speed and direction are constant until it fizzles out. This should actually look pretty cool when you're turning the ship, or dramatically changing acceleration.

Cheers.

Scott Smith
@knight666: Note that when you stop the particles will just... hang there. I think what you probably *really* want is what Scott suggested
BlueRaja - Danny Pflughoeft