[Question] Playing animations backward?

Hello,

I was looking inside some C++ header (like AnimBlueprint, Skeleton or even AnimMontage) to figure out if there was a way to play an animation backward on a skeleton ? Is this possible ? That could be helpful in case you want to rewind an action (for example in a game where you can control the time elapsed).

Edit : I would also ask about rewinding an animation, which is a bit more precise than simply playing backward. Imagine that the player runs forward then reverse the time, he starts to run backward from its previous animation state. The idea here is that the animation will play backward from its current time position instead of its end point.

Is that possible too ?

Heya Fabrice,

As Rama mentions, you’re looking for Play Rate. In the animation Blueprint for a skeletal mesh, animation sequences and blendspaces have support for negative Play Rate. In the image below, I’ve created a variable called Play Rate, and exposed the Play Rate property as a pin on the animation sequence and blendspace nodes.

I’m not a familiar with the code side, but a quick search shows that PlayRate, GetPlayRate, SetPlayRate exist in many animation classes.

As for reversing time, entire games build their mechanics around reversing time (and just reversing it), and there’s much to consider, just off the top of my head:

  • AI logic that can handle being reversed and acting the same given the same variables
  • Player transform recording
  • Key event logging (ex firing a rocket)
  • Logging where a that rocket was fired from
  • Remembering a rocket exploded in the time frame that allows rewinding, re-creating that destroyed asset
  • VFX/SFX reversal
  • Giving the player back ammo upon reversal (or any other expended resource)
  • Resurrecting and enabling controllers for any killed AI (or simply preventing the controllers from being destroyed until such a point that there’s no way they could be brought back, ex: a “dead, but not really dead” state)
  • Setting the newly resurrected AI’s state to match what they where (assuming you destroy them)
  • Removing anything from the player he/she may have picked up (or any resource gained)
  • Putting said items back into the world (think about an RTS game with trees you cut down, or an FPS where you pick up keys)
  • Re-locking any container/doors the player may have unlocked (or any other state based object)
  • Physics Simulation… not even sure where to start with that
  • And I’m sure hundreds of other things that get more intense when you consider many systems are built to assume time progressing forward

Much of this is just state switching, which you could record, but you have to deal with the fact that you are using system resources to do all of this, so some other portion of the game will not be as performant or will have to be scaled back.

Excellent ! Thanks a lot for the other hints. I was aware it was not an easy task, but maybe not that much. :slight_smile:

(Thanks to Rama too for his quick answers.)

Dear Fabrice,

This issue is being looked at.

It should be simple, you can see how it should work by using a negative playrate on the animation sequence.

this works in the editor, buuuut does not work in the montage (you should be able to set a negative playrate when you play the montage via C++ code)

It is a bug being fixed

https://rocket.unrealengine.com/questions/13223/anim-montage-playing-montage-in-c-with-1-play-rate.html

Rama