Rolling a ball using Expressions

I’m currently prepping a much larger series of tutorials, but to take a break from those, I’ve also be creating a series of short tutorials for the things I go back to again and again – but not so frequently that I have them memorised. I find myself searching the internet (and the Cow of course) for these tips, but then often have to wade through a 30 minute tutorial – just to find that one thing… that one trick. Well, these mini-tuts are built for that purpose. I hope you find them useful.

This tutorial uses an expression to calculate how much a circle / image should rotate based on its horizontal position. I’ve then adapted the expression slightly to help you roll 3D objects too.


————————————————————————————–
Expressions:

2D Layer
diameter=width;
pi=Math.PI;
circumference=diameter*pi;
rot=360/circumference;
Xpos=thisLayer.transform.position[0];
scalePercent=thisLayer.transform.scale[0]/100;
rot*Xpos/scalePercent
CC Sphere in one dimension:
diameter=effect(“CC Sphere”)(“Radius”)
pi=Math.PI;
circumference=diameter*pi;
rot=360/circumference;
Xpos=thisLayer.transform.position[0];
scalePercent=thisLayer.transform.scale[0]/100;
rot*Xpos/scalePercent
CC Sphere coming towards camera:
diameter=effect(“CC Sphere”)(“Radius”)
pi=Math.PI;
circumference=diameter*pi;
rot=360/circumference;
Xpos=thisLayer.transform.position[0];
scalePercent=thisLayer.transform.scale[0]/100;
rot*Xpos/scalePercent*-1

Project file: http://bit.ly/2ZtSDn6

Published by ShiveringCactus

Tutorials and videos, mainly After Effects, but with some 3D and puppetry stuff too.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: