p = ParticleEffect()
p.loadConfig("smokering.ptf")
How do i access it’s properties? What I want to do is to create some base system and alter some of it’s stats depending on it’s final use with my code (mainly stuff related to it’s scale).
If all you want to do is manipulate the transform data of your particle system, then you do so like you would for any other nodepath:
p = ParticleEffect()
p.loadConfig("smokering.ptf")
p.start(parent = render, renderParent = render)
#you want to manipulate the scale:
p.setScale(scale)
#hpr:
p.setHpr(hpr)
#pos:
p.setPos(pos)
#etc.
For all other parameters of the particle system, I would suggest using the particle panel to set those [it’s use is explained in section 21. of the manual], as it is much more convenient than doing it manually, and then loading your system into the scene graph.
One way to do what you want is to manually stop the particle effect using a task. You’d need to know how long your particle effect is going to last, say for instance 5 seconds. After starting your particle effect, start the task that checks if 5 seconds or more have elapsed since the particle effect started playing. If five seconds or more have elapsed, then kill the particle effect, using p.disable() or p.cleanup() if you want to completely remove the particle effect, after that, remove the task as well:
#function to end particle effect:
counter=0
def manipulate_particle_system (time_condition,task):
global counter
if(counter>=time_condition):
#end the particle effect:
p.disable()
#end the task:
taskMgr.remove("task-name")
counter+=1
return task.again
#start the particle effect:
p.start(parent = render, renderParent = render)
#start your task, make it executed every second:
taskMgr.doMethodLater(1,manipulate_particle_system, "task-name", extraArgs=[5], appendTask=True)
That’s one way to do it, though I’m not sure if its the best way!
I have submitted a patch for review, which should fix the crash.
The issue was that you didn’t assign spawn templates. When you set spawnOnDeath to True, it will respawn
one of the assigned spawn templates. However, if you set no spawn templates, there will be a modulo by zero, causing a crash.
However, for your case, if you don’t want the particle system to respawn, you should use set_spawn_on_death_flag(False) I believe.
I’m not sure what spawn templates are, I couldn’t find any api reference to it, I just found them in the code.
From what I understood, when the particle system stops, it will select a random template from the list of assigned spawn templates, and spawn that. (You can add them with add_spawn_template).
Hm, I’d expect set_spawn_on_death(False) to not make it respawn. I’m not too sure what the method does tho, it might be worth experiencing with the other api methods.
The version with underscores is valid since Panda3D 1.9 (or earlier?). Interrogate (the python wrapper generator) generates a version with underscores, and a camel case version, however only the camelCase version is shown in the API.
The PEP 0008 suggests not using camelCase, and instead using lower_case, so the preferred way is using lower_case (although its not used in many places in panda yet).
About the fix, well you’d need to get a development version of Panda3D to get the fix. Maybe rdb will backport it to 1.9 tho.
EDIT:
Looked a bit through the source, it looks like set_spawn_on_death controls whether to spawn a new particle when an existing particle dies.