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

How to parent rotation property to change position of another shape layer?

New Here ,
Apr 24, 2024 Apr 24, 2024

Hi, I'm trying to make an animation with one shape layer that rotates, and another layer that moves with the rotation, but horizontally. Is there any way to parent the rotation property to the other shape layers horizontal position? To explain the attached photo: I want the lines under the round shape to move when I rotate the round shape, like a scroll effect horizontally. 
Thanks!
/Jo Skärmavbild 2024-04-24 kl. 19.05.06.png

TOPICS
Expressions , How to
1.0K
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 , Apr 24, 2024 Apr 24, 2024

I would use the diameter of the wheel to calculate the circumference (C = π D) and use that to move the layer in x. This expression would do that and also compensate for any scale changes in the Wheel layer.

 

src=thisComp.layer("Wheel");
d = src.sourceRectAtTime().width;
r = src.rotation / 360;
s = src.scale[0] * .01;
c = d * s;
x = Math.PI * c * r;
value + [x, 0];

 

Wheel.gif

 

 

Translate
LEGEND ,
Apr 24, 2024 Apr 24, 2024

A simple linear() expression will do with this pattern:

 

linear(refValue, refStart, refEnd, start, end)

 

All that's required is to fill in the links to the properties and set the values.

 

Mylenium 

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
New Here ,
Apr 24, 2024 Apr 24, 2024

Thank you so much! When you say "fill in the links", what do you mean? I'm a total beginner when it comes to expressions, should have written that in the post, sorry! 

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 ,
Apr 24, 2024 Apr 24, 2024

If you wanted Layer 1's rotation from -90 to +90 to correspond to a horizontal movement of 0 to 100 for Layer 2, you could use a position expression like this:

r = thisComp.layer("Layer 1").transform.rotation;
rMin= -90;
rMax = 90;
xMin = 0;
xMax = 100;
x = linear(r,rMin,rMax,xMin,xMax);
value + [x,0]

 

 

 

 

 

 

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 ,
Apr 24, 2024 Apr 24, 2024

I would use the diameter of the wheel to calculate the circumference (C = π D) and use that to move the layer in x. This expression would do that and also compensate for any scale changes in the Wheel layer.

 

src=thisComp.layer("Wheel");
d = src.sourceRectAtTime().width;
r = src.rotation / 360;
s = src.scale[0] * .01;
c = d * s;
x = Math.PI * c * r;
value + [x, 0];

 

Wheel.gif

 

 

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
New Here ,
Apr 25, 2024 Apr 25, 2024

Wow, thank you so much! Is there any way to make the lines move the opposite way?

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
New Here ,
Apr 25, 2024 Apr 25, 2024

Never mind, I figured it out! Thank you, all of you, for the help! 

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
New Here ,
Apr 25, 2024 Apr 25, 2024
LATEST

One more question though, haha. Is there any way to do the same thing but for the wheel rotation to parent the number on an animated number count (text layer)? Let's say I wanted the number to start with "1860" and then be able to count upwards to ""2024". 
I apologize if I'm pushing it haha. 

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