If there’s a performance issue here, it’s probably simply that each time you fire a bullet, you start an interval that will run for the next 500 seconds, and will continue to run long after you stopped caring about the bullet.
If you press the fire button only once per second, then after five minutes of gameplay you would have 300 lerp intervals still running. That’s going to have an effect on performance.
To solve this problem, you need to keep a pointer to your lerp intervals, and associate them with each bullet. Then when you remove the bullet, you also finish the interval.
I’m not talking about reducing the duration of the interval. I’m talking about explicitly cleaning it up when you’re done with it. If you don’t clean it up, it’s going to cause a performance leak, and it’s your fault, not Panda’s.
There’s no lerp bug. I think you’re still not cleaning them up properly.
The problem might be here:
self.fire = [None for x in range(self.sizeBULLETS)]
This is completely reassigning self.fire to a new list of intervals. Trouble is, if self.fire was already a list of intervals from the last pass, then those intervals are leaked, and will not get cleaned up any more.
Still, intervals are complicated to use, and I’m not sure they’re the right tool for a bullet anyway. If you’re not 100% sure of the interval system, but you have another solution that works well for you, then go ahead and use your other solution.
i have already a other solution working, but the lerpInterval seemd for me more comfortable.
self.fire = [None for x in range(self.sizeBULLETS)]
about this piece of code, i cant imaging that this is the problem, its only def. the size of the fire array. i will check this in few hours, now i take a nap
you said i have to init a lerpInt. for each bullet, which slows down everything dramatical.
i hope the lerp bug will be fixed soon
about cleaning it up, how??? i used the “finish” statement for the lerpInterval and cant find anything else to cleaning it up.
...
//here im def. the interval for each bullet...
for x in range(self.sizeBULLETS):
if (self.sizeBULLETS > 0):
print self.sizeBULLETS
self.fire[x] = LerpPosInterval(self.bullets[x], 500,ship.getPos(), other = self.bullets[x])
self.fire[x].start()
...
//and here im finishing the interval
self.fire[x].finish()
I think Drawr right. I thought you had the same bug as the post below you had cus I know lerp used the .setPos. Um… actully you have another bug too I am surpise it didnt give you a error… maybe i’m wrong but you called fire = None… yet you still have one called fire too (the task) wouldnt that cus some problems?
Untested but I think this is what your going after in that code.
y = 0
self.bullet = {}
self.timerX = 0
def fire(self,task):
if (key["fire"]!=0):
self.fire1()
for x in self.bullet:
self.fire[x] = LerpPosInterval(self.bullets[x], 500, ship.getPos(), other= self.bullets[x])
self.fire[x].start()
for x in self.bulle:
if self.bullets[x].getZ() >= 10:
if task.time >= self.timerX + 2:
self.bullet[x].removeNode()
self.fire[x].finish()
#You'll need to fixs the timer if it doesnt work right.
if self.timerX <= task.time
self.timerX = task.time
def fire1(self):
y = y + 1
self.bullet[y] = loader.loadModel("models/test2008")
self.bullet[y].setPos(ship.getPos())
self.bullet[y].setP(90)
self.bullet[y].setScale(2,2,2)
self.bullet[y].setColor(1,0,0,0)
self.bullet[y].reparentTo(render)
maybe im doing this. it wont make much work, im havin only textured planes in. thats why i wasnt mind any scale. but, for my point of view, the scale should make no performance difference! and the lerp cant be finished while the duration!