Proposal: expand animation range / repeat parameters

Started by Crimson Wizard, Sat 15/06/2024 15:25:44

Previous topic - Next topic

Crimson Wizard

While I've been working on a pathfinding API, where functions like WalkPath and MovePath were added, others suggested to add a way to instigate a "patrol" mode over a single path, where character would move back and forth. In other words, something like a Repeat parameter, but which would tell to alternate directions instead of repeating same direction.

This reminded me that I was thinking of expanding RepeatStyle enum for Animations a while ago.

At some point I noticed that in the engine RepeatStyle consists of 3, not 2, variants, except one of them is "hidden" and supported only for a deprecated AnimateObject function (iirc). This third variant is "OnceReset", which means that the animation is played once, but then reset to the starting frame, as opposed to stopping at the last frame.
Unfortunately its support is inconsistent, and this constant is not a "official" part of RepeatStyle enum in script.

Anyway, I've been thinking about expanding animation parameters, which, I suppose, could be also applied to any function that involves a repeatable action, such as WalkPath.

The idea is to have a standard group of parameters for this. Such as:
- start frame
- end frame
- RepeatStyle
- direction, which means "starting direction".

Start frame and end frame would define a (optional) range of frames, and RepeatStyle would define how the animation is run between them.

The RepeatStyle I've been thinking was:
- Once - goes from start to end frame and stops at end frame;
- OnceReset - goes from start to end frame and resets to start frame;
- OnceAndBack - goes from start to end frame, and then goes backwards to start frame;
- Repeat - loops between start and end frame, using the starting direction;
- RepeatAlternate - loops between start and end frame, changing direction each time it reaches either of these two.

Range parameters should be made so that it's possible to have wrapping ranges, e.g. in a loop of 0-10 frames one may have a starting frame 8 and ending frame 4, so that animation went 8,9,10,0,1,2,3,4 if direction is forward.

Do you see any other useful options here?



Another thing, while thinking about this, I realized that logically there's a place to add a "Tween style" (or "easing") in this list of parameters, if we'd like to implement "tweening" into the engine (at least to functions like Animate).

eri0o

Quote"tweening" into the engine (at least to functions like Animate).

This looks interesting but I don't understand how tweening works in a frame by frame animation. Is this for the frame offsets?

Crimson Wizard

#2
Quote from: eri0o on Tue 22/07/2025 12:39:04
Quote"tweening" into the engine (at least to functions like Animate).

This looks interesting but I don't understand how tweening works in a frame by frame animation. Is this for the frame offsets?

No, my meaning was frame timing. If the whole animation duration is represented as 1.0, the tween controls the current progress between 0.0 and 1.0, and engine would choose a frame based on that value.

Snarky

Quote from: Crimson Wizard on Tue 22/07/2025 15:29:14No, my meaning was frame timing. If the whole animation duration is represented as 1.0, the tween controls the current progress between 0.0 and 1.0, and engine would choose a frame based on that value.

I think I can imagine use-cases where this would be useful, but is it such a generally useful feature that it makes sense to build it into the engine rather than rely on some fairly simple scripting with the Tween module?

Personally I think it is better to keep things simple.

Crimson Wizard

Quote from: Snarky on Tue 22/07/2025 17:30:10I think I can imagine use-cases where this would be useful, but is it such a generally useful feature that it makes sense to build it into the engine rather than rely on some fairly simple scripting with the Tween module?

That is why in my earlier post I added a "if we'd like to implement "tweening" into the engine".

brushfe

These options are all fantastic! These would really help animation give characters and objects more life. I was just wishing for RepeatAlternate in an idle animation this morning. I hope it works out!

SMF spam blocked by CleanTalk