Material flipbook animating too quickly

I’m working on animating a sprite sheet inside of a material, I’m trying to get it to play at exactly 30 fps, which I thought could be accomplished by wiring the Time node in directly:

This plays too quickly, which makes me think I’m doing something wrong- I’ve seen some examples where Time gets wired through Frac * 0.4 or Frac *1, but I really don’t understand what the purpose is there; is there any way I can very purposefully specify a target fps that it should always animate at?

Edited to add: I think I’m missing something bigger here, because I noticed that it doesn’t always start playing from frame 0: if I create four instances of the same material, one right when the game starts, and three more at 0.25 second intervals, all four materials animate in sync, meaning that the fourth one actually starts a full 1 second into its animation. I know I’m not technically “animating” so much as I am juggling the UV coordinates, but is there any way I can explicitly start or stop the animation? Its utility is somewhat limited if I can’t make sure that it always starts at frame 0 and stops playing at the terminal frame.

The flipbook function will by default play the entire sequence once per second. The clue to this is that it says “Animation Phase 0-1” on the input pin. That means 0 is the start, and 1 is the end.

if you hook up Time, time increases by 1.0 every 1 second, so you will loop through all frames in that second.

To control frame rate, you need to divide by how many frames you want to display in 1 second. Ie, if your flipbook had 30 frames, it would be at 30fps. If your flipbook has 64 frames, you’d need to multiply time by 30/64, or 0.46875. Then it will only complete 30 frames in 1 second.

Ooh that makes a lot more sense, for some reason I had it in my head that the animation phase somehow automagically worked out to 30fps if you were giving it Time, thank you for the detailed explanation!

I don’t suppose there’s an obvious way to reset the loop via an external method? I’m trying to wire this up to play like a traditional animation (e.g. one method starts it playing from frame 0, another method pauses/stops the animation), I can achieve the pause effect by wiring a variable into the Animation Phase and setting it to 0 on demand, but is it correct that the flipbook node can’t actually be “reset” or called to start playing from a specific frame on command?

One common way to do this would be to create a Material Instance Dynamic. Then you can use a ScalarParameter instead of Time, and specify what the value is using a blueprint. You could use simple ticking math to increment the value, or use a curve asset, or place a timeline in the BP event graph. Plenty of options to control things. You can also drive it using a sequencer track.

2 Likes

Ooh, that’s a really great idea- I was unaware that you could set ScalarParameters from BP, and that combined with your patient explanation of how the animation phase works (which I still have trouble braining, even though I see exactly how it functions now) was more than enough to get what I was trying to do working; thank you again for your patience! :slight_smile:

Hi Ryan

I hope you guys are still around to answer this but,

Is there any way to control the Animation Phase with Cascade’s Dyamic module using Dynamic Parameters set up in the Beam material?

I’m using whats been discussed above for a Beam based flamethrower effect, so I really need to be able to control it like any SubUv flipbook, as much as I can.

I’d like for the flipbook to start and end throughout its lifetime instead of looping forever, with no reference on which frame to start with.