The current vertex frame or texture frame number of a model or sprite, and the target frame for frame interpolation.

Model and sprite entities can consist of any number of frames in order to display animation. In case of sprite entities, the animation frames must be of the same size, side by side in the graphics file. The number of sprite frames must be given at the end of the file name after a '+' sign, like "explo+7.pcx" (the total length of the file name must not exceed 20 characters):

There are two ways to animate a model or sprite entity. If the entity consists of several frames, but has no action attached, it will cycle automatically through its frames with a rate of 8 frames per second for models, and 12 frames per second for sprites. If it has an action attached, it won't animate by itself. Instead, it's frame value (1.. number of frames) gives the number of the current frame. Thus by permanently adding time_step to the frame parameter the model can be animated.

Alternatively, for a walking model, the distance covered could be added to frame, instead of a time factor. If the frame parameter has a fractional part, the model's shape will be interpolated between the frame number given by the integer part, and a target frame given by the next_frame parameter. If next_frame is set to 0, frame+1 will be used as target frame. This way, a model can smoothly morph forwards or backwards between arbitrary frames.


1 .. max frame number (default: 1)





my.frame += 1.5*time_step; // gives 16/1.5 = 12 frames per second
my.frame %= 10; // don't exceed the number of frames 

Example for a loop function that uses next_frame to smoothly animate a model between frames 20 and 30:

my.frame = 20; // set to start frame
while (1) 
{ my.frame += time_step; // 16 frames per second if (my.frame > 30) { my.next_frame = 20; } // interpolate to start frame else { my.next_frame = 0; } // interpolate to FRAME+1 if (my.frame >= 31) { my.frame -= 10; } // if end frame reached, skip back wait(1); }

See also:

ent_animate, ent_blend ► latest version online