I've made a nice looking effect of a smoke trail from a launched rocket. When it works, it looks great, however, it only works about 1 out 10 or 20 shots. Sometimes the smoke particles are losing alpha transparency too. (I'm using the Flake.dds file that came with DP)
Here is the emitter's creation.
if Phys = 1
Effects(ef).emitter = FreeObj()
cx# = object position x(Effects(ef).weapid)
cy# = object position y(Effects(ef).weapid)
cz# = object position z(Effects(ef).weapid)
Effects(ef).img = TexSmoke
phy make particle emitter Effects(ef).emitter,250,0.001,cx#,cy#,cz#,2.0,0.0,1.0,0.0
texture object Effects(ef).emitter, Effects(ef).img
phy set emitter life span Effects(ef).emitter,0.0003
phy set emitter size Effects(ef).emitter,8.0
phy set emitter max size Effects(ef).emitter,4.0
phy set emitter growth rate Effects(ef).emitter,1.0
phy set emitter start color Effects(ef).emitter,255,255,255
phy set emitter end color Effects(ef).emitter,0,0,0
phy set emitter linear velocity range Effects(ef).emitter,-2.0,-2.0,-2.0,2.0,2.0,2.0
phy set emitter linear velocity Effects(ef).emitter,5.0,3.0,5.0
phy set emitter collision scale Effects(ef).emitter,0.5
phy set emitter fade Effects(ef).emitter, 1
ghost object on Effects(ef).emitter, 0
set object light Effects(ef).emitter, 0
endif
and here is the update each loop to follow the rocket.
if Effects(z).effect = RocketFire
if object visible(Effects(z).weapid)
if Effects(z).emitter > 0
cx# = object position x(Effects(z).weapid)
cy# = object position y(Effects(z).weapid)
cz# = object position z(Effects(z).weapid)
if Phys = 1
phy set emitter position Effects(z).emitter, cx#, cy#, cz#
endif
endif
else
if Effects(z).scolor = 256
Effects(z).start = timer()
endif
if (abs(timer() - Effects(z).start) < 5000) and (Effects(z).scolor > 0)
dec Effects(z).scolor
if Phys = 1
phy set emitter start color Effects(z).emitter, Effects(z).scolor, Effects(z).scolor, Effects(z).scolor
endif
else
delete object Effects(z).weapid
Gosub ClearEffect
endif
endif
endif
This code basically moves the emitter along with the rocket, and fades the smoke trail over time once the rocket has impacted and been removed from the scene.
I just can't figure out why the effect doesn't show every time, and why the texture is all white sometimes.