Play a Flipbook after another one
The question is simple, the answer ... I do not know :P I'm want to play an animation when another animation stops. Example:
How's the best way? (I was deselect the loops)
I'm thinking... maybe I need to create a integer variable. On Tik event do a Switch. If the variable is 0 set "fliipbook 1", If the variable is 1 set "flipbook 2", if variable is 3 set "flipbook 3". Is that OK?
First things first, let's take a look at that documentation, shall we? ^^
This is the UPaperFipbook: https://api.unrealengine.com/INT/API/Plugins/Paper2D/UPaperFlipbook/index.html Here you can get access to the duration of the animation using GetTotalDuration(). If I'm not mistaken, then you could initiate a timer that is set to conclude after the length of the animation.
This is the UPaperFlipbookComponent: https://api.unrealengine.com/INT/API/Plugins/Paper2D/UPaperFlipbookComponent/index.html It boasts the function OnFinishedPlaying() which is called when a non-looping animation finishes.
Here's an example I found in another answer of this being used: https://answers.unrealengine.com/questions/312702/problem-about-onfinishedplaying-flipbook.html
So, you would call your ChangeSprite() function using OnFinishedPlaying(). You could even store the next animation to play elsewhere and feed it in as an argument, perhaps even with the option to exit out of the current animation early like so:
I'm sorry I can't blueprint this right now, or even test the code for that matter, but hopefully this could get you started!
If you need more help, then just ask! I don't actually have time to put anything together right now, but if needed I certainly can try in the near future.
Regarding deciding which animation to play: take a look into state machines. UE4 has a decent animation state machine tool for 3D animations, but I'm currently unaware of whether there is a sprite state machine built into the engine, or whether you would have to concoct your own.
A switch on index would work too, however, though it is advisable to only use such a system if it is relatively simple.
answered Jul 08 '18 at 10:28 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here