Restore object after played UMG timeline

I want to know how to restore all the objects which have been animated back to theirs original state using blueprint.

Details:

I create a widget which has three images. Then I add a UMG timeline animation, and at the end of the animation, I hide all the three images and remove the widget from the viewport. That works fine.

When I want to display them and play animation again, I add the widget to viewport, But the images stays in hidden state which is the end state of the previous animation. So, is there any restore function in blueprint to reset the objects state?

There are a couple of ways to do this:

  1. Directly set the properties.
    If you have an animation which fades a widget out. Before you render it again, set the opacity back to 1.0.

  2. Play the animation backwards.
    Using the “Play Animation” node, set it to reverse and it’s start time to 0.1.
    I have had issues with reverse animations previously. So sometimes I will create a specific animation for reversing the action.

283509-resetanimation.png

So you mean there is no engine function which records the original data such as position, visiblity, opacity before playing animation. We need to record/handle the data through different ways, such as create a new widget, or reverse the animation or something else. Right?

I think you are absolutely right.
I quickly read the source code just now, and there is no recorded data for playing animation. And I think the engine designer is right, engine don’t know what I will do with the widget after playing animation.
So record original data, and then set back the data after animation ended is the correct way.

That is correct. Think of timelines as just manipulating data over a series of frames. What state the object is before/after is irrelevant to it.

UMG animation is backed by sequencer. Internally, there is the capability of storing pre-animated values and restoring them after playback. Sequencer is set to do this by default. The mechanism just hasn’t been exposed to UMG, but it can be enabled. We’ll consider adding this in a future release.

Here’s the documentation for Sequencer regarding restore state:

https://docs.unrealengine.com/en-US/Engine/Sequencer/HowTo/WhenFinished/index.html