Ok, I’ve used projectile intervals before with no problems but I’m having a slight problem here. We’re making a tank game and when the tank hits a collision polygon (in front of a ramp, for example), a “jump” animation gets called on the tank, which is essentially a projectile interval. A jump dummy node is parented to the tank (in front of it) which is used as the end position of the interval.
The problem is that after each jump, the tank doesn’t go all the way back to the same vertical position, specifically Z = 0. It ends up floating in the air, around Z = 1.5 something. And on EVERY jump it gets a little higher. I’m stumped.
Here’s the tank getting initialized:
(all in the tank class, self.model is the tank model)
TANK_START_POS = Point3(-107.8,21.4,0)
TANK_START_HPR = Vec3(-270,0,0)
# set the position and hpr
self.model.setPos(TANK_START_POS)
self.model.setHpr(TANK_START_HPR)
Here’s the jump dummy node getting made:
TANK_JUMP_DISTANCE = 150
# dummy node used for jumping
self.jumpDummyNode = loader.loadModel("models/sphere.egg")
self.jumpDummyNode.reparentTo(self.model)
self.jumpDummyNode.setColor(1,1,1)
self.jumpDummyNode.setPos(0,-TANK_JUMP_DISTANCE,0)
#self.jumpDummyNode.hide()
and finally the jump function:
TANK_JUMP_DURATION = 2
def jump(self, collisionEvent):
# set the jumping boolean to true
self.isTankJumping = True
# turn off the dust particles
self.p0.setLitterSize(0)
self.p1.setLitterSize(0)
# get the endPos
endPos = Point3( self.jumpDummyNode.getNetTransform().getPos() )
# set up the jump interval
self.jumpInterval = ProjectileInterval(self.model,
endPos = endPos,
duration = TANK_JUMP_DURATION)
# do the jump, then reset the jumping boolean
Sequence( self.jumpInterval, Func(self.resetIsTankJumping) ).start()
# end jump
Any ideas? I’m really stumped here.
Thanks in advance,
Adam