[Closed] Particles inheriting visibility from emitter
Hello,
i’m working on a small script here and I’m stuck. I would appreciate some pointers to figure this out.
I’m generating particles with a PF Source. They are generated at an emitter object called myEmitter. This object’s visibility is animated (it appears and disappears). I want the generated particles to inherit the emitter’s visibility at the time they were generated.
Or plain human language: I’m using the particle system to create a long-exposure effect of a car’s headlamps (like this) and I want to animate the turn signals on the car as well.
This is what I got:
on Proceed pCont do
(
count = pCont.NumParticles()
the_source = $myEmitter
for i in 1 to count do
(
pCont.particleIndex = i
if pCont.particleAge == 0 do
(
pCont.visibility = bezier_float()
pCont.visibility.controller.value = the_source.visibility.controller.value
)--end if age
)--end i loop
)--end on
But it doesn’t seem to work. I’m guessing that there is no such thing as pCont.visibility. Is there anything I can do? The only other solution I can think of is to animate the particle’s material, link a particle’s age to that material animation and use particle age to control the particle’s transparency. But it seems quite convoluted and I don’t want to start messing around with it until I’m sure there is no other possibility. I would appreciate any input.
You could go that route or use something like Ghost Trails (commercial) or Trail (freeware), which will do trails for you.
-Eric
Cool! These will come in handy when I make the next scenes. Thanks!
However, I don’t want to redo this scene so I solved it using an animated texture tied to particle age. Still, this seems QUITE cumbersome to me. I also would like to know for the future: is there REALLY no other way to control the transparency of a particle?! 🙁
The only way I know is through materials, it is like a sub object of a mesh/poly object. You can only control its transparency through materials/maps. In reality particles are a subobject of the system that created them. There is no visibility parameter per particle. The only other option I can think of would be through scaling by age.
-Eric
Wow, that’s surprisingy inflexible. But thanks for clearing that up.
By the way, I realized that I misunderstood fundamentally how partcile scripts work. The example above is awfully wrong. Here is a working one. It is also a simpler solution. Instead of a script operator this is just a birth script. It simply stops emitting particles when a specific object is invisible. I may not have transparency but since I animate a turn signal, it’s all I really need.
on ChannelsUsed pCont do
(
pCont.useTime = true
pCont.useAge = true
)
on Init pCont do
(
)
on Proceed pCont do
(
t1 = pCont.getTimeStart() as float
t2 = pCont.getTimeEnd() as float
if (t1 < -50*(4800/25)) then (t1 = -50*(4800/25))
if (t2 < 100*(4800/25)) do -- 100 frames
(
for i in (t1/8+1) to (t2/8) do
(
curTime = 8*i as float
curFrame = curTime/(4800/25)
at time curFrame
(
myVis = $myEmitter.visibility.controller.value
)
if myVis != 0 do (
pCont.AddParticle()
pCont.particleIndex = pCont.NumParticles() -- last particle that was added
pCont.particleTime = curTime/(4800/25)
pCont.particleAge = 0
)
)
)
)
on Release pCont do
(
)
Note that I use 25FPS. Emitting starts at -50 and ends at 100.