Issue with Actor animation/ Sequence

Hello,
i am attempting to combine footstep sounds with an Animation like so:

def animWalk(self):
            def sfx():
                print('footstep')
                self.footstep.play()
            w1 = Func(self.charM.loop, 'walk', fromFrame=1, toFrame=8)
            footstep=Func(sfx)
            w2=Func(self.charM.play, 'walk', fromFrame=9, toFrame=16)
            if self.walkseq==None:
                self.walkseq = Sequence(w1,footstep, w2)
            # if self.walkseq.isPlaying()!=True:
            if self.anim!="walk":
                    self.walkseq.start()

With this, however, it only plays the sfx and loops the second part of the animation, completely skipping over w1.

Printing getCurrentFrame() shows that it plays from frame 9 to 16, then None before playing the sfx and starting over again(from frame 9).

I suspect that “Func” intervals may finish immediately, rather than remaining until they’re considered to be “done”. (After all, there’s nothing apparent to tell the Func that its work isn’t done as soon as the call to “loop” returns, I daresay.) As a result, “w1” is concluded before the animation has a chance to take visible effect.

For animations, I might suggest instead using “actor intervals”–being designed for use with animation, I imagine that they will conclude only when their animation concludes.

1 Like

I see. I switched to ActorIntervals, and was able to get it to work. However, I want to use Func() intervals so I can blend the animation as well. I can’t seem to find anything regarding blending between Actor intervals, would you happen to know if that is possible?

Thanks!

1 Like

Ah, that I don’t know, I’m afraid. I very rarely use intervals of any sort, preferring other approaches (like timers handled by update-methods).

1 Like