Particle life and ai

I’ve just purchased PC and I have to say I am seriously impressed with it so far.
There are a couple of things I’d like to know if it is possible to do if someone could help me out…

1: I have a sprite that is moving around the screen on it’s own, picking objects up as it goes. I’d like the particles from an emitter to face the sprite and chase after it. Is that possible?

2: Is it possible for a particle to have a (for want of a better term) health bar, so that instead of having a predetermined life span it will only die when its life runs out?

Cheers. [import]uid: 7841 topic_id: 10975 reply_id: 310975[/import]

1.) You could use a FX Field that attracts particles and move that field according to the player’s position. This should basically work.

2.) You can directly access each particle (see GetParticle() ) and apply any properties to them. Keep in mind, however, that particles are removed automatically as soon as one of the following conditions is true:

  • If the alpha of a particle reaches zero.
  • If the scale of a particle reaches zero.
  • If the lifetime of a particle exceeded.
  • If the killOutsideScreen property was set to true and a particles left the visible screen area.

To remove particles, you can loop through them and simply set the internal .killTime property of a particle to a value smaller than the current time. This will remove the particle:

[lua]local numParticles = Particles.GetMaxParticles()
local Particle
for i = 1, numParticles do
Particle = Particles.GetParticle(i)
if Particle ~= nil then
– TELL PARTICLE CANDY TO REMOVE THIS PARTICLE:
Particle.killTime = 0
end
end[/lua]

[import]uid: 10504 topic_id: 10975 reply_id: 40093[/import]