Copy link to clipboard
Copied
Hey guys,
I suck at expressions, but I think one would really help me here. I have a car driving, part of a complicated precomp, and i want the wheel rotaion in the precomp to rotate according to the position of the car in the master composition. I've seen a few link-rotation-to-position scripts but can't find one that i can figure out how to alter in order to make it work.
Hope someone can help, and apologize in advance if this is well worn territory. I tried a search but could have easily not used the right key words.
Thanks in advance,
Mike
The comp and layer names need to be in quotes.
Dan
Copy link to clipboard
Copied
Assuming that you're talking about horizontal movement and the width of your wheel layer is the same as the wheel's diameter, the relationship will be like this:
x = comp("Main Comp").layer("Car").transform.position[0];
360*x/(Math.PI*width)
If you want to tie the rotation to how far the car has moved, you might do it like this:
P = comp("Main Comp").layer("Car").transform.position;
x = P[0] - P.valueAtTime(0)[0];
360*x/(Math.PI*width)
Dan
Copy link to clipboard
Copied
Thanks Dan,
I can't tell you how helpful your expressions are, though I'm sure you hear that all the time.
So, this is probably just down to my lack of understanding, but it's giving me this error...
After Effects warning: Class ‘global’ has no property or method named ‘SC_05_DOOR’
Expression disabled.
here's how i used the script:
P = comp(SC_05_DOOR).layer(THEROD2).transform.position;
x = P[0] - P.valueAtTime(0)[0];
360*x/(Math.PI*width)
The main comp is "SC_05_DOOR" and the precomp is "THEROD2" and within that there's the actual car with the wheels called "CAR SC SIDE"
Thanks for everything,
Mike
Copy link to clipboard
Copied
The comp and layer names need to be in quotes.
Dan
Copy link to clipboard
Copied
Aw dangit, i thought that was you telling me what to change. I thought i was being smart by taking them out. I won't assume that about myself again...
Thanks so much Dan!!!
Find more inspiration, events, and resources on the new Adobe Community
Explore Now