Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

linking precomped wheel rotation to position in another comp

Contributor ,
Feb 09, 2011 Feb 09, 2011

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

TOPICS
Expressions
4.5K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Feb 09, 2011 Feb 09, 2011

The comp and layer names need to be in quotes.

Dan

Translate
Community Expert ,
Feb 09, 2011 Feb 09, 2011

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Feb 09, 2011 Feb 09, 2011

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 09, 2011 Feb 09, 2011

The comp and layer names need to be in quotes.

Dan

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Feb 09, 2011 Feb 09, 2011
LATEST

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!!!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines