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

Parenting an object to x-axis motion only of another object whose motion is driven by several nulls?

Enthusiast ,
Apr 04, 2023 Apr 04, 2023

Copy link to clipboard

Copied

So this doesn't seem like it should be an overly complex thing to set up, but I haven't been able to figure out how to do it. I'm still kind of a novice when it comes to expressions...

 

I have a crane-like object rigged up, carrying a payload that sways back and forth a bit to simulate the inertia of a large, heavy object. I'd like to add a "shadow" underneath the payload object; it needs to match the x-axis movement of the "payload", but ignore the y- (and z-) axis motion. The tricky part is that the "payload" is parented to a "hook", which is parented to the head of the crane, which is parented to part 1 of the crane arm, which is parented to part 2 of the crane arm, etc. etc. The "payload" itself has no keyframes and no moving properties itself -- the motion is driven entirely by the various other layers parented througout the chain. My workaround is to brute force it, throwing everything into a subcomp that I track using Mocha, then strip out all movement other than the x-axis, but there must be a better way to do this. Any suggestions?

TOPICS
Expressions , How to , Scripting

Views

205

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

correct answers 1 Correct answer

Community Expert , Apr 04, 2023 Apr 04, 2023

Something like this should give you the x position of the payload layer:

L = thisComp.layer("payload");
x = L.toWorld(L.anchorPoint)[0];

That will be useful if you want the shadow directly under the payload. However, if the shadow is offset from the payload and just want the shadow to move the same x amount as the payload, then you could do something like this to calculate the offset:

L = thisComp.layer("payload");
x = L.toWorld(L.anchorPoint)[0];
x0 = L.toWorld(L.anchorPoint,0)[0];
xOffset = x 
...

Votes

Translate

Translate
Community Expert ,
Apr 04, 2023 Apr 04, 2023

Copy link to clipboard

Copied

Something like this should give you the x position of the payload layer:

L = thisComp.layer("payload");
x = L.toWorld(L.anchorPoint)[0];

That will be useful if you want the shadow directly under the payload. However, if the shadow is offset from the payload and just want the shadow to move the same x amount as the payload, then you could do something like this to calculate the offset:

L = thisComp.layer("payload");
x = L.toWorld(L.anchorPoint)[0];
x0 = L.toWorld(L.anchorPoint,0)[0];
xOffset = x -x0;

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
Enthusiast ,
Apr 04, 2023 Apr 04, 2023

Copy link to clipboard

Copied

LATEST

Thanks, @Dan Ebberts! That did the trick!

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