[Closed] Particle flow script operator
Hi all
Im quite new to maxscript and would say Im ok with particle flow.
What I want seems quite simple but im struggling to get something working as I want. Basically froma collision event I want to spawn an amni light and have its multiplier controlled by the age of the particle, Ie flash on impact, and also the omni light to spawn in the collision impact space.
on ChannelsUsed pCont do
(
pCont.useposition = true
)
on Init pCont do
(
ppos = pcont.particleposition
o=omnilight()
o.pos = [ppos]
)
Im activating the particle.position channel, then adding it to the omni position spawn but its spawning at 0,0,0 ( default.
If I put o.pos = [50,50,50] then the light spawns at that position so I guess its a way of extracting the position data and using it that I cant get ? Any ideas or point toa similar tutorial would be much apprechiated.
cheers guys
Will
First of all, you are reading the particle position of particle with index 1, because you have not specified which particle in the container to use (pCont.particleIndex = someIndex).
It is of course quite possible that the particle with index one actually has a position of [0,0,0] – have you tried printing out the pcont.particlePosition to see what the script sees?
Also, ‘o.pos = [ppos]’ is wrong syntax, I would expect it to crash. ppos is already a Point3 value, so ‘o.pos = ppos’ or even ‘o.pos = pCont.particlePosition’ should do.
Also, it is a BAD BAD idea to CREATE an omni light inside the handler! Each time you run your animation in the viewport, a new light will be created. If you render, it might actually cause a crash or other problems. You should pre-create the lights to use either manually or in the ‘on init pCont do()’ handler and collect them in the init handler if they already exist to avoid the creation of thousands of lights. The MAXScript Reference has a chapter on what NOT to do in PFlow Script operators, and creating objects is one of the things you should be careful about.
Incidently, the latest series from CG-Academy entitled “The PFlow Script Show” deals with all these issues and actually creates the setup you described (flashing lights on collisions, even including acquiring the color from the collision point). Just in case you are interested (see my signature).
Cheers for the pointers Bobo.
Im currently trying to get your dvds on order at work. Hopefully they should come in before xmas. For the meanwhile I have been playing with trying to get this working. I think I will hold off on this idea until they arrive.
thanks again for the reply.
Will.