Convert anim frame number to Pawn.AnimFrame

Tutorials and discussions about Mapping - Introduce your own ones!
User avatar
Barbie
Godlike
Posts: 2153
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Convert anim frame number to Pawn.AnimFrame

Post by Barbie » Mon Aug 02, 2021 1:45 pm

Several mesh sequences consists of multiple discrete sequences, but the comment to the value AnimFrame in class'Pawn' suggests another unit of measurement:

Code: Select all

class Actor extends Object
...
var(Display) float        AnimFrame;     // Current animation frame, 0.0 to 1.0.
From my experiments is it the percent value of the complete animation?

Example: Sequence 'Dead2' of Mesh 'UnrealShare.Nali1' has 16 frames. To set the last frame #15 I have to use 1 / 16 * 15 = 0.9375.
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett

User avatar
Feralidragon
Godlike
Posts: 5378
Joined: Wed Feb 27, 2008 6:24 pm
Personal rank: Work In Progress
Location: Liandri

Re: Convert anim frame number to Pawn.AnimFrame

Post by Feralidragon » Mon Aug 02, 2021 1:58 pm

Yes, and it's in relation to the total number of frames:
AnimFrame = CurrentFrame / NumFrames
for all actors and meshes, it doesn't matter if it's a Pawn or something else.

Some things to note here:
  • CurrentFrame starts at 0, not 1, meaning that if you have 2 frames, when you reach the 2nd the calculation results in 0.5 and not 1.0 (for 3 frames it would be 0.66.., and so on, it increases with the number of frames);
  • CurrentFrame represents the progress between frames, so it's a floating point number that increases over time as the animation is executed (0.0, 0.1, 0.2, ..., 1.0, 1.1, ...);
  • The reason why the calculation is performed this way, where 100% animation completion does not correspond to an AnimFrame of 1.0 is because the value 1.0 represents a full return from the last frame to the first frame.
In other words, if you have 4 frames for example, you don't get 1.0 once you reach the 4th frame, you get 0.8, and the values between 0.8 and 1.0 is the tweening that takes place to return from the last frame to the first frame.