x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Play a Flipbook after another one

Hi!!!

The question is simple, the answer ... I do not know :P I'm want to play an animation when another animation stops. Example:

  • Play a flipbook whith a man dancing.

  • When the flipbook is finished play another flipbook with the man jumping.

  • When the last flipbook is finished play another flipbook with the man.... i don't know... crying XD

How's the best way? (I was deselect the loops)

Thanks! ^^


EDIT:

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?

Product Version: UE 4.19
Tags:
more ▼

asked Jul 08 '18 at 04:41 PM in Blueprint Scripting

avatar image

Charditronic
5 1 1 6

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

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:

 .h
 
             // Function bound to USpriteComponent::OnFinishPlaying
             UFUNCTION()
             void FinishPlaying() {
             PlayNextAnimation(NextAnimation)
         }
 
         // The next animation to be played 
         UPaperFlipbook* NextAnimation
 
 .cpp
 
         GetSprite()->OnFinishedPlaying.AddDynamic(this, &MySpriteCharacter::FinshPlaying);
 
 
         // System for choosing next animation  -  currently a crude switch statement 
         void PickNextAnimation() {
             switch (int) {
             case 1:
                 NextAnimation = JumpAnimation;
                 break;
             case 2:
                 NextAnimation = DanceAnimation;
                 break;
                 ...
             }
         }
 
         // Calling this before the end of the animation will force a change.
         void PlayNextAnimation(UPaperFlipbook* AnimationToPlay) {
             GetSprite()->SetFlipbook(AnimationToPlay);
         }

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.

more ▼

answered Jul 08 '18 at 10:28 PM

avatar image

Greywacke
240 7 9 15

avatar image Charditronic Jul 10 '18 at 08:49 AM

Thanks for your answer, it is very complete! It's not Blueprints but I understand the idea. I'm going to try it right now

avatar image Greywacke Jul 10 '18 at 09:11 PM

Great, if it does work, then please mark as 'answered' for other users :)

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question