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

I can't link rotation to both X position and Y position of another layer

New Here ,
Aug 04, 2023 Aug 04, 2023

Copy link to clipboard

Copied

I am using this expression for rotating some wheels along with the movement of the vehicle body:

comp("compositionName").layer("layerName").transform.position[0]

 

Now, that would be perfect if I had a car that moves horizontally, but my vehicle is also moving along vertical walls or inclined walls (and upside down).

 

That's why I need my wheels to rotate when the body layer's Y position and X position changes. If it's not possible to consider both the axis at the same time, I would like to consider X as a priority, but if that is still, to check Y position. 

 

Thanks!

TOPICS
Expressions

Views

148

Translate

Translate

Report

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
LEGEND ,
Aug 04, 2023 Aug 04, 2023

Copy link to clipboard

Copied

Perfectly and easily possible. You simply multiply the rotation amount with a cosine and sine based on the inclination angle, respectively. You would just have to remap them through linear() functions to get whatever value ranges you need and you may need a safeguard for when the sinus/ cosinus values turn to zero at specific 90 degree angles. Something like this perhaps:

 

mCar=thisComp.layer("Car");
mPos=mCar.transform.position;
mRot=degreesToRadians(mCar.transform.rotation);

//angular multipliers

mX=linear(Math.cos(mRot),0,Math.PI,0,1);
mY=linear(Math.sin(mRot),Math.PI,0,1,0);

//fictional circumference of the wheel

mCirc=mPos%500;

mCirc*mX*mY;

 

This isn't exact, but should give you the basics. It could be fancied up in a million ways like calculating the actual circumference/ distance travelled based on the wheel diameter and of course tweaking the rotation ranges.

 

Mylenium

Votes

Translate

Translate

Report

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 ,
Aug 04, 2023 Aug 04, 2023

Copy link to clipboard

Copied

I JUST used something similar to this about an hour ago to chain together rectangles in an attempt to create a curvature effect in Classic 3D, since Cinema 4D lite is so slow and limited. Too bad AE's rendering of 3D alpha pixels is not accurate enough and allows colors from behind to come through the seams. Back to hacking my way through Cinema 4D lite

Votes

Translate

Translate

Report

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 ,
Aug 04, 2023 Aug 04, 2023

Copy link to clipboard

Copied

LATEST

iExpressions is the easy way. Here's a tutorial:

The key to getting the rotation correct is calculating the circumference of the wheel. That's just Math.PI * width.  

 

I'm leaving for a fishing trip right now, but if someone else has the time, they can give you the length of a line at an angle. I don't want to give you an incorrect expression, but it's just the length of the hypotenuse. Just use that to determine the rotation multiplier.

 

Or, spend a few bucks and just buy iExpressions.

Votes

Translate

Translate

Report

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