Hello all
I made this code to make a model been created constantly (like a particle system)
class Stars(DirectObject):
def __init__(self):
self.stars=[]
taskMgr.add(self.create,"starCreate")
taskMgr.add(self.starMove,"starMove")
def create(self,task):
self.pos =
Vec3(random.uniform(-5,5),random.uniform(99, 100),random.uniform(-2,2))
self.galaxy=loader.loadModel("star")
self.galaxy.reparentTo(render)
self.galaxy.setScale(1)
self.galaxy.setPos(self.pos)
self.stars.append(self.galaxy)
return Task.cont
def starMove(self,task):
for i in range(len(self.stars)-1,-1,-1):
self.stars[i].setY(self.stars[i].getY()-1)
if self.stars[i].getY()<10:
self.stars[i].detachNode()
return Task.cont
Although I detach every node that its Y value less than 10 but the game begin to slow down after a while
I also read about RigidBodyCombiner but the problem is that I have to call rbs.collect every time (self.create) being done and manual doesn’t support that
Is there any idea about this??
Thanks in advance