2017

Table Of Contents
The dagger's rotation is created through the dagger's rotation of its negative Y-axis towards the direction of
its movement and the rest of the dagger spins one full rotation around this same axis every 32 frames. The
align function is used to generate the rotation vector.
ExpressionChannel
align(dagger_axis.position, (0,-1,0), frame * 2 * PI / 32)dagger_axis.rotation
Dagger, Apple, and Cherry
To see this example, load the setup named expressions_dagger_apple_cherries into Action. This animation
points a dagger at either a moving apple or moving cherries, whichever is closer in position at the time.
The dagger's rotation is created by the dagger's position as the dagger points its negative Y-axis in the direction
of either the apple or the cherries, whichever happens to be closest. The length function is used to find the
distance between the dagger and the other objects, while the if function is used to determine which is the
shorter distance. The lookat function is used to generate the rotation vector.
ExpressionChannel
if(length(cherries_axis.position - dagger_axis.position) <length(apple_axis.position
- dagger_axis.position), lookat(cherries_axis.position, dagger_axis.position, (0,-1,0),
(1,0,1)), lookat(apple_axis.position, dagger_axis.position, (0,-1,0), (1,0,1)))
dagger_axis.rotation
1274 | Chapter 24 Animating Keyframes