ok
it took me a while, but i have something close to what you said using global variables.
First i created two list, one to keep track of all the “dummies” and another for all the vfx’s
also i define the max number of vfx’s possible (max_vfx)
lvfx is a global variable to know the index of the last vfx spawned
list_dum = []
max_vfx = 10
lvfx = 0
list_vfx = []
then i load the model, the “dummies” and set the inputs from the keyboard
base.enableParticles()
config = configparser.RawConfigParser()
# search for specific file with dummi positions positions
config.read('model/Dummies.txt')
Dum = config.items('Dummie')
self.t = Actor("model/fox_tutorial", # Load our animated charachter
{'walk': "model/fox_tutorial-walk_cycle"})
self.t.reparentTo(render)
# Put it in the scene
self.t.actorInterval("walk", playRate=2).loop()
#if input 7 start function loadmultiVFX with arguments [Actor, particle file, Tag]
self.accept('7', loadmultiVFX, [self.t, 'fireish.ptf', '1'])
#if input 8 disable all the tagged vfx's
self.accept('8', disableallvfx)
for dummy in Dum:
data = dummy[1].split()
list_dum.append(self.t.exposeJoint(None, 'modelRoot', data[0]))
list_dum[-1].setTag("ID", data[1])
and then i have a vfx’s function than manage were and what to spawn from the inputs
and one to disable all in the list
def loadmultiVFX(t, filename, tag):
# t = Actor
#get variables lvfx and max_vfx
global lvfx, max_vfx
# find tagged with (ID = tag ) in list of dummies
for i in list_dum:
if i.getTag('ID') != tag:
pass
else:
if lvfx >= max_vfx:
#restart last vfx index if is bigger than max_vfx
lvfx = 0
if max_vfx != len(list_vfx):
list_vfx.append(ParticleEffect())
list_vfx[-1].loadConfig(Filename(filename))
list_vfx[-1].start(t)
list_vfx[-1].reparentTo(i)
lvfx += 1
print(f'last vfx {lvfx}')
else:
list_vfx[lvfx].disable()
list_vfx[lvfx].loadConfig(Filename(filename))
list_vfx[lvfx].start(t)
list_vfx[lvfx].reparentTo(i)
lvfx += 1
def disableallvfx():
global lvfx
lvfx = 0
for i in list_vfx:
i.disable()
TAE fox spawn in legs and clean - YouTube
i still have some junk with the cycles and it only works if i disable()
the particles, cleanup()
brakes it, but that will be for future me.
the next step would be about hurt and hit boxes
i saw you did a fighting game
how did you manage them?