Animating with the Channel Editor > Expressions > Function Reference >
Animation Functions

Use the following functions to animate channels in a general way.

NoteArguments shown in square brackets are optional. For example, in the syntax of the align function, the options [AxisToAlign] and [BankingAngle] are optional.

align

Returns a rotation vector such that a designated axis of an object is aligned with the direction of the object's movement. You can also bank the rotation around the axis. The result should usually be assigned to a rotation channel.

Syntax: | align(PosToFollow, [AxisToAlign], [BankingAngle])
Arguments: | PosToFollow is the vector representing the channel to align on, typically an animated position. AxisToAlign is the vector representing the axis with which to align, by default the X-axis (1,0,0). BankingAngle is the angle in radians by which to rotate the result about the AxisToAlign (performs banking). If the BankingAngle argument is specified, the AxisToAlign argument must also be specified.
Example: | align(axis.position, (0,0,1), frame * PI / 8) returns a rotation vector that points the object's Z-axis in the direction of its motion while the rest of the axis rotates along this axis.

lookat

Returns a rotation vector based on an object's position that points it towards a second moving object. The result should usually be assigned to a rotation channel.

Syntax: | lookat(TargetPos, ObserverPos, [AlignVector], [UpVector])
Arguments: | TargetPos is the vector of an object's position channel that you want the rotation vector to point towards. ObserverPos is the vector of the position channel from which you are looking. AlignVector is the vector of the direction that you want to have looking at the target, by default the Z-axis (0,0,1). UpVector is the vector of the direction that you want to be pointing upwards, by default the Y-axis (0,1,0). The UpVector should be set to a different vector than the AlignVector. If the UpVector argument is specified, the AlignVector argument must also be specified.
Examples: | lookat(followed_axis.position, follows_axis.position) returns the rotation vector required so that follows_axis points its Z-axis towards followed_axis. lookat(followed_axis.position, follows_axis.position, (0,1,0),(1,0,0)) returns the rotation vector required so that follows_axis points its Y-axis towards followed_axis, with its X-axis pointing upwards.

eval

Returns the value of a given expression at another point in time.

Syntax: | eval(Expression, FrameNumber)
Arguments: | Expression is the expression to be evaluated. This can be any valid channel value. FrameNumber is the frame to simulate when evaluating the given expression.
Examples: | eval(axis1.position.x, 5) returns the value of axis1.position.xat frame 5. eval(axis1.position, frame - 10) returns the axis1.positionvector at 10 frames behind the current frame. eval(axis1, frame / 2) returns the entire axis1 channel at half the normal speed.

if

Returns one of two values based on the result of a conditional test. You can nest multiple functions inside each other to handle multiple results.

Syntax: | if(Condition, TrueValue, FalseValue)
Arguments: | Condition is any channel or expression. When comparison operators are used, a true expression evaluates to 1 and a false expression evaluates to 0. See Comparison Operators. TrueValue is the value to be returned for any non-zero result. FalseValue is the value to be returned if Condition evaluates to 0.
Examples: | if(axis.position.y >= 100, 5, -5) returns 5 when axis.position.yis greater than or equal to 100, and -5 otherwise. if(frame < 10 || frame >20, 100, 200) returns 100 when the current frame is less than 10 or above 20, and 200 otherwise. if(axis.position.x, 6, 7) returns 6 when axis.position.x is something other than 0, and 7 when it is 0. if(axis.position.x == 100 && axis.position.y != 200,8, 9) returns 8 when axis.position.x is 100 and axis.position.y is not 200, and 9 otherwise. The next four examples all equivalently return 5 when neither axis.position.x nor axis.position.y are greater than or equal to 0, and -5 otherwise. if(!(axis.position.x =>0 || axis.position.y =>0), 5, -5) if(!(axis.position.x =>0) && !(axis.position.y =>0), 5, -5) if(axis.position.x < 0 && axis.position.y < 0, 5, -5) if(axis.position.x < 0, if(axis.position.y < 0, 5, -5), -5)

ease

Returns a number from 0 to 1 representing a smooth S-curve transition between a given range of frames. All frames before the start frame are assigned 0 and all frames after the end frame are assigned 1. A start weight and end weight specify how the S-curve is formed.

Syntax: | ease(StartFrame, EndFrame, [StartWeight], [EndWeight])
Arguments: | StartFrame and EndFrame are the frames at which the transition starts and ends respectively. StartWeight and EndWeight are numbers that specify how curvature is distributed at the start and end of the curve respectively. To get an S-curve, their sum should be less than 1, otherwise a square curve will result. In addition, if either of these two arguments are specified, the other must also be specified.
Examples: | ease(10, 50) * 100 returns a standard S-curve from 0 to 100between frames 10 and 50. 80 - ease(1, 40) * 20 returns a standard S-curve from 80 to60 between frames 1 and 40. ease(1, 30, 0.2, 0.2) * 50 + 10 returns a tight S-curve from10 to 60 between frames 1 and 30. ease(10, 80) * 150 yields the following curve: ease(10, 80, 0.2, 0.2) * 150 yields the following curve:

bell

Returns a set of values representing a bell (normal distribution) curve over time. You can specify the centre frame number and height and width characteristics of the curve.

Syntax: | bell(CentreFrame, Height, Width)
Arguments: | CentreFrame is the frame number at which the bell curve will reach its maximum height. Height is the maximum height of the bell curve. Width specifies the horizontal distribution of the curve.
Examples: | bell(10, 100, 3) returns a bell curve centred around frame10 with a maximum height of 100 and a width distribution of 3. bell(50, 150, 10) yields the following curve: bell(50, 150, 20) yields the following curve: