Trouble blending anims

Hi, I am attempting to blend between a “walk” and a “run” animation based on the value of the joystick. I have it set up like this:

`

 def animWalk(self):
   x = self.leftJoystick
   self.char.enableBlend
   self.char.setControlEffect('walk', 1-x)
   self.char.setControlEffect('run', x)
   if self.char.getCurrentAnim()!='walk' and self.char.getCurrentAnim()!='run':
      self.char.loop('walk)
      self.char.loop('run)`

this is called during a task, and it results in the model posing somewhere between the two animations. Any help is greatly appreciated!

I think that the problem might be that the code above (ignoring the missing inverted comma after “walk”, which I imagine is a typo) should cause the program to restart the “walk” and “run” animations on each frame that its run. As a result we only see (presumably) the first frame of each, blended together.

This is because, if I’m not much mistaken, there is only one “current anim”, and thus its value will be either “walk” or “run”–not both. Thus a check of “getCurrentAnim() != ‘walk’ and getCurrentAnim() != ‘run’” will always find one of those conditions to be “False”, and so overall return “False”.

Instead of that check, I’d suggest getting the individual animation-controls for those two animations and seeing whether they’re playing. Like so:

walkControl = self.char.getAnimControl("walk")
if not walkControl.isPlaying():
    self.char.loop("walk")

runControl = self.char.getAnimControl("run")
if not runControl.isPlaying():
    self.char.loop("run")
1 Like

That was it, thanks!

1 Like