Category: Animations
Since engine version: 1.0 OC


The value increases or decreases (depending on whether end is smaller or larger than begin) linearily in time (in frames). Initially the value is set to position and it is moving towards end. One cycle from begin to end lasts for length frames. If position and begin are not the same then end will be reached earlier already. on_ending specifies what happens once the end is reached.


array Anim_Linear(int position, int begin, int end, int length, int on_ending);


Start value. Should be inside the interval given by begin and end.
Start of the interval.
End of the interval. If end is larger than begin then the value increases linearily with time, otherwise it decreases.
Number of frames for the animation to be played from begin to end.
Specifies what happens once end is reached. There are the following possibilities:
Constant Value Description
ANIM_Loop 0 Once end is reached the value is reset to begin so the cycle restarts.
ANIM_Hold 1 Once end is reached the value remains constant.
ANIM_Remove 2 Once end is reached the corresponding animation is removed the same way as if StopAnimation were called to the exact point in time. For combination nodes the child node with the smaller weight is removed.


See the animation documentation for further explanations of the animation system.


var start = 0;
var end = GetAnimationLength("Turn");
if(GetWind() < 0)
  start = end;
  end = 0;

if(GetWind() != 0)
  SetAnimationPosition(GetRootAnimation(5), Anim_Linear(GetAnimationPosition(GetRootAnimation(5)), start, end, 7200/GetWind(), ANIM_Loop));
  SetAnimationPosition(GetRootAnimation(5), Anim_Const(GetAnimationPosition(GetRootAnimation(5))));
Sets the speed with which the animation in slot 5 is played depending on the wind speed. If the wind blows to the left then the animation is played backwards. Another possibility would be to set the position each frame using Anim_Const, however with the solution using Anim_Linear it is enough to call the function every couple of frames since the windmill continues to turn with contstant speed between calls (in other words, it is assumed that the wind speed will not change much for small time intervals).
See also: Anim_AbsX, Anim_AbsY, Anim_Action, Anim_Const, Anim_Dist, Anim_R, Anim_X, Anim_XDir, Anim_Y, Anim_YDir, PlayAnimation, SetAnimationPosition, SetAnimationWeight, StopAnimation
Clonk-Karl, 2010-01