Actor setCurrentFrame() or setT()?

How can I change the current frame of an actor animation which is already playing?
I couldn’t find a function for that. I though I could use stop(), then loop() again by setting the fromFrame argument, but it sees to start playing from the fromFrame again when looping. Also, I think this isn’t a very nice way to do it, as you might notice the single frame when the character is stop()'ped, but loop() isn’t yet called.

You use pose() to set the actor to a particular frame. That will also stop it from playing, so you can follow it up with an immediate call to loop(restart = False) to continue looping from that point (and return to frame 0 at the end of the loop).

No frames will be drawn between your calls to pose() and loop(), or between any two other function calls you make in the same task, assuming you are not using threading or something silly like that. The frame is only drawn when none of your tasks are running, so it doesn’t matter how much you allow things to be temporarily incorrect as long as it’s correct by the time you finish your task.

David

That did the trick.
A question though: why is it that when I set a fromFrame to a number and restart to 1, the animation still doesn’t restart from frame 0?

Actor.loop(fromFrame = x) means to loop over the frames from x to the end of the animation (as opposed to the default, which is to loop over the frames from 0 to the end of the animation). If you add restart = True (or restart = 1), all it means is to forget the current frame, and start from the beginning of the loop, which is frame x.

If you want it to loop from frame 0, then you should not include fromFrame in the loop() call.

David

I thought fromFrame meant from where to start playing/looping and ‘restart = 1’ meant to restart the animation (if looped) from frame 1 instead).

No. fromFrame and toFrame define the range of frames over which you want to loop. The default is the whole animation. restart = False means to begin playing from the current frame; restart = True means to begin playing from fromFrame.

David

current frame?

The current frame the animation is showing right now. For instance, whatever you last set it to with pose(), or wherever it happened to be when you called stop(), or whatever.

David