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).

SMF spam blocked by CleanTalk