I’m looking for a way to pause all actors and then restart them with the same playing properties. This is for actors with blended animations on so it’s possible multiple animations are playing with different loop & restart values.
I’m willing to keep a handle of all actors myself though if there’s an easy/efficient way to get a list of all actors in the tree (ie- if there’s already a list somewhere in panda) that’d be great to know. Mostly what I would like help with is how to store the state of the current animations and reload them.
For example- say I have an actor with animations Walk, and Wave.
I call pause when the actor is looping the walk animation and playing the wave animation once. When I unpause, I want to make the actor start both those animations from the correct spot with the correct settings.
Thanks for any help!
Panda doesn’t keep a list of Actors anywhere, and there’s no way to pull an Actor handle out of the scene graph (you’ll just get a plain NodePath if you try). So it’s up to you to store the list of Actors. Fortunately, Python makes this pretty easy to do.
You could also, I suppose, play games with the clock, if you want to globally pause all animations at once–for instance, you can pause the clock altogether. But that would be pretty magic and hacky, and therefore probably not a great idea.
Oh, yeah. In general, Panda doesn’t store the state of the animations in any global place, either, so it might be best if you keep track of that too.
But note that the “animation state” is really stored in the Actor’s AnimControls, and there is a separate AnimControl for each animation. All of the play(), stop(), loop(), etc. methods on Actor are really just a pass-through to the appropriate AnimControl.
You can call actor.getAnimControls() to get a list of all currently-playing AnimControls on the Actor (or a list of all AnimControls with a particular name, or whatever). You can then pause each of these individually, and restart them later. Thing is, there’s not an interface to ask whether it’s currently looping or just playing, so it’s difficult to know exactly how to restart it unless you have recorded this information independently.
Well- that’s what I was afraid the answer was : )
Thanks for the fast response!
When you mention this, I wanted to add a "stopwatch " for my game that would then stop when the player finshed the course or “died” and log the time for a FASTEST TIMES category.
Would I use this method (mentioned in the above quote) to do this…or is there a better more reliable way? Thanks!
Just use something like:
startTime = globalClock.getFrameTime()
at the start of the race, and
endTime = globalClock.getFrameTime()
at the end of the race. Then subtract the two to get the amount of time spent in the race.
Cool! Thanks for the great info