Elegant Solution - C++ (Easily expandable to Blueprints)
1 - You can put in UPaperSprite objects directly into any UImage.So ultimately it is possible
2 - You just need to simulate the UPaperFlipbookComponent Tick(or use the Component itself and call TickActorComponent() wherever you want.Don’t have to attach it to an actor)
Here’s the c++ snippet I use
FDateTime AnimStartDate;
UPaperFlipbook* AnimFlipbook;
UImage* AnimImage;
void StartAnimation()
{
AnimStartDate = FDateTime::Now();
}
void TickAnimation()
{
FTimespan sTime = FDateTime::Now() - AnimStartDate;
float sSeconds = sTime.GetTotalSeconds();
//Animation is done
if (sSeconds >= AnimFlipbook->GetTotalDuration())
{
//Loop
{
AnimStartDate = FDateTime::Now();
}
//Or End
{
//Do end logic
}
}
else
{
AnimImage->SetBrushResourceObject(AnimFlipbook->GetSpriteAtTime(sSeconds));
}
}
Very easy to accomplish.If you need more control over how to animate, you can check UPaperFlipbookComponent to see how they change the play rate.Or directly use the Component to tickand register the correct frame to put into the image