You should apply this expression to the xRotation property of a sequence of 3D layers (pictures) that are distributed in the Z-axis. The Anchor point of each layer should be at the bottom of the later.

The expression checks automatically the height of each picture and the distance between adjacent pictures to make the movement accurate and independent of the pictures' size and spacing. You can put as many pictures as you want.

Code: Select all

```
pi = Math.PI;
D = length(transform.position,thisComp.layer(index+1).position);
H = thisLayer.height;
a1 = -Math.asin(D/H)*180/pi;
b = thisComp.layer(index+1).transform.xRotation;
a2 = b - Math.asin(D/H*Math.cos(b/180*pi))*180/pi;
T = 1;
t = time - index*T;
(t<=0) ? 0 : ( (t<=T) ? linear(t,0,T,0,a1) : a2)
```

Code: Select all

```
T = 1;
t = time - index*T;
(t<=0) ? 0 : linear(t,0,2*T,0,-90)
```

I've attached a Project File that uses this expressions for a sequence of white solids, that are distributed in Z-depth (using a Position expression), and includes some lights and couple of cameras:

Camera 1: Shows the animation from a distance.

Camera 2: Uses an expression to move the camera and follow the domino movement.

Start with Camera 1 to see the behaviour, and then switch Camera 1 off to see the more interesting movement of Camera 2.

The lights also follow the domino movement using an expression.

You can use the Null 1 object to control the animation:

T - controls the speed of the animation

dt - controls the spacing between the pictures (don't put more than 1.18 or the pictures will be too far from one another to make a contact when they fall, and expression will go crazy...)

Enjoy !

Koby.