I'm trying to adapt a script that splits particles but I've hit an annoying problem and can't figure it out.
The script originally did THIS.
What I've now got it to do is split to extra emitters.
I was telling it the emitter to add to, for example:
But then I decided I wanted the particles to be sent to a random emitter.
I've tried quite a few ways but I keep getting errors and it is getting on my nerves.
Here is a bit of the script but it has everything you'd need to see:
Code: Select all
#Get some emitters
greenEmitter = scene.get_PB_Emitter("Green")
blueEmitter = scene.get_PB_Emitter("Blue")
purpleEmitter = scene.get_PB_Emitter("Purple")
orangeEmitter = scene.get_PB_Emitter("Orange")
#Make a list with emitter names
emitterList = ["greenEmitter", "blueEmitter", "purpleEmitter", orangeEmitter]
randEmitter = random.randint(0,3)
randModulo = random.randint(3,9)
#If frame is equal to the below value
if (frameCheck == 6):
#Get the particles IDs
getGreenIDs = greenParticles.getId()
#If a particle ID has a remainder of randModulo
if ( getGreenIDs %randModulo):
#Get the particles position
particlePos = greenParticles.getPosition()
#And its velocity
particleVel = greenParticles.getVelocity()
#Add the particles to the random emitter
#And remove it from the Green emitter
#WARNING: Script error: "'str' object has no attribute 'addParticle'" at line number
This works and prints each emitter name randomly
I've tried different variations:
I've tried different variations, all of which don't work. For example:
(emitterList[randEmitter] + ".addParticle(particlePos, particleVel)")
I know I'm missing something obvious here but can't figure out what.