Hi guys, sorry to bother, but I’m hitting my head against a big problem that showed up since I switched from v1.5.4 to v1.6.2
Here is the task that moves my “Player” class.The self.model is an Actor with many animations; I designed it so that it has 4 main states: jumping, attacking, paused, and normal (this one doesn’t define a variable).
Jumping is obtained adding vertical velocity to the CollisionHandlerFloor that controls the self.model Z.
def move(self, task):
if self.HP<=0:
messenger.send("death")
return task.done
#camera handling (if mouse is on the window)
if base.mouseWatcherNode.hasMouse() and not self.isPaused:
#base for the calculations
startPos=self.model.getPos()
anim=str(self.model.getCurrentAnim())
if anim[0:3]!="atk":
self.isAttacking=False
#"landing" check
if self.floorHandler.isOnGround() and self.isJumping:
self.isJumping=False
self.floorHandler.setVelocity(0)
mPos=base.mouseWatcherNode.getMouse()
if mPos[0]>=.998:
base.win.movePointer(0, 2, base.win.getPointer(0).getY())
elif mPos[0]<=-.999:
base.win.movePointer(0, base.win.getXSize()-2, base.win.getPointer(0).getY())
Hz=180*mPos[0]
Hy=-15+35*mPos[1]
data=Functions.castCam(self.R, Hz, Hy)
base.camera.setPosHpr(startPos[0]+data[0], startPos[1]+data[1],
startPos[2]+data[2], -Hz, Hy, 0)
if self.isAttacking:
pass
elif self.isJumping:
self.model.setPos(self.model, self.step*globalClock.getDt()*self.speedValue)
self.model.pose("run", 1)
else:
self.step=Vec3(0, 0, 0)
if base.mouseWatcherNode.isButtonDown(KeyboardButton.asciiKey("w")):
self.step.addY(-2)
if base.mouseWatcherNode.isButtonDown(KeyboardButton.asciiKey("a")):
self.step.addX(.5)
if base.mouseWatcherNode.isButtonDown(KeyboardButton.asciiKey("s")) and self.step[1]==0:
self.step.addY(.5)
#elif base.mouseWatcherNode.isButtonDown(KeyboardButton.asciiKey("s")) and self.step[1]!=0:
elif base.mouseWatcherNode.isButtonDown(KeyboardButton.asciiKey("s")):
self.step.addY(2)
if base.mouseWatcherNode.isButtonDown(KeyboardButton.asciiKey("d")):
self.step.addX(-.5)
if self.step!=Vec3(0, 0, 0):
self.model.setHpr(180-Hz, 0, 0)
self.model.setPos(self.model, self.step*globalClock.getDt()*self.speedValue)
if self.step[1]<0:#this checks if the player moves forward
self.model.setPlayRate(1.5, "walk")
self.model.loop("walk", restart=0)
elif self.step[1]>0:#this checks if the player moves backward
self.model.setPlayRate(-1.2, "walk")
self.model.loop("walk", restart=0)
else:
self.model.loop("idle1", restart=0)
return task.cont
The problem I’m getting is that when the model is moving forward, the “walk” animation is played only once, the freezes as in self.model.pose(“walk”, 1).
Instead, when it’s playing backward, the problem never shows!
Also the idle animation freezes after 1 loop.
A little variation, sometimes it runs fine for 3-4 loops, then freezes to death.Playing attacking anmations or performing jumps doesn’t remove the problem.
I tried to see if the problem was in the animation: I exported the model from Blender with chicken both R56 and R71b, same show.
But, I noticed that putting
self.model.setPlayRate(-1.2, "walk")
in the moving forward animation removes the freeze.
So: if an animation is looped forward, it freezes, if backward it’s fine.
The problem however may be in my code, for if I use the Ralph model with its own animations, the freeze shows up no matter what.
Any help is appreciated