Animations and slowing down time

Is there a way to scale the playback speed of all animations – a scalar applied to the delta-time provided to the internal animation system, perhaps?

To explain, I’ve implemented a simple effect that “slows down time”: aside from certain elements (such as intervals involved with moving the GUI around), I apply a scalar to my update method’s dt value, causing everything to move more slowly. However, animations continue to play at their usual rate, which looks somewhat odd – we have, for example, characters walking slowly but moving their legs at the usual rate.

I don’t want to run through all animations and set their play-rate: that seems inefficient, and may interfere with other pieces of code that affect play-rate (such as the code that scales the speed of the walking animation with a character’s movement speed).

There’s not specifically an interface to do this, though you could I suppose experiment with changing the global clock and slowing down all time everywhere in Panda (including all intervals).

Or, you could consider using AnimIntervals to run your animations (instead of the interface), and then your animations will slow down when you slow down your intervals by whatever means you’re doing.



At the moment my “time scaling” is simply a float scalar applied to my update task’s delta-t value, which is then passed into the update methods of the various game objects. If I were to use animation intervals, how might I go about slowing down an interval already in progress?

As to interfering with the global clock, I don’t particularly want to affect everything: as I mentioned above, I have a few elements that I want to have run at normal speed.

Otherwise, where does the delta-t for animation updating come from? Is there somewhere that I might intercept it, somehow, or a class that I might sub-class in order to override the updating of the animation system?

All of this is very hacky, unfortunately. The character animation system gets its time directly from the global clock. So does the interval manager. And these things are distributed through several classes, so there’s not a single place to override and change this behavior.

You could in principle change the global clock, then run the interval update task, then change it back, I suppose. Or similarly for computing all of the animations. But that sounds like a terrible idea.



All right, in that case is there perhaps some way that I might achieve my effect of “slowing down time” other than my current method? Is editing the global clock feasible – perhaps by sub-classing it in order to get hold of any methods that might be useful to override – and then applying an inverse scalar to elements that I want to be unaffected be the scaling?

Changing the global clock behavior is easy to do, and doesn’t require subclassing; there are methods exposed on the ClockObject class to do pretty much anything. And yes, it is feasible to slow down the global clock but inversely accelerate things that you want to remain unaffected.


Fair enough – that seems like a good solution. Thank you! :slight_smile:

It may also be worth experimenting with the idea of using a second ClockObject if the APIs you are using support using a custom ClockObject instance for the operations that you want to be slowed down or sped up.

Interesting, if perhaps a bit heavy for what I was working on; thank you nevertheless. :slight_smile: