Expression Library

Throw

Author: Chris Wright

The Throw expression for After Effects allows you to move an object at a constant velocity without keyframing.

Code Sample

Hover over the code and click the copy button.

				
					veloc = 20; //horizontal velocity (pixels per second)
x = position[0] + (time - inPoint) *veloc;
y = position[1];
z = position[2];//delete this line for 2D layers
[x,y,z]//delete the z variable in this array for 2D layers
				
			

Other Notes

Apply this expression to the position transform property of your layer. Note that the following expression is written for a 3D layer. Remove the “z” function (line 4) and the “z” variable in the line 5 array to use on a 2D layer. As written this expression will affect the x position only. To affect the y or z position, cut the code from the plus sign onwards in line 2, and paste it to lines 3 or 4.