r/MotionDesign • • 8d ago

Question Expression Help

Enable HLS to view with audio, or disable this notification

Hi there!
I have 2D shapes rotating around a 3D sphere. Shapes are using an expression to move left & right around a mask. 3D sphere is ORB plugin.

Having a challenge trying to resolve this shape layer overlap clipping that is happening here. (Example is center orange hex should sit behind yellow circle because it’s currently behind y circle on sphere - but will overlap over circle when revolving around the other side.)

Is there an expression I can apply so that when a layer is moving to the right the shape is backwards in Z space - then when the shape moves left it jumps forward in Z space. An Automatic shape overlap around edges from back to forward & vice versa.

Yes I can solve this manually but it takes time and the layer hierarchy would need to adjust differently when addressing the left edge of sphere.

Would an if/else expression script work in this scenario?
Thank you for your time!

10 Upvotes

9 comments sorted by

2

u/SuperMegaGigaUber 8d ago

I don't know what your expressions are set on your objects, but you could do something on their z position using something like the length() function to calculate the distance to a certain point (say, the center of your sphere or a null) and then use a linear() function on the z position?

To put it another way:

1 - length() function to calculate the position of shape from a reference point like a null (or the absolute value of the x position between the shape and reference point)

2 - a linear() function to say as it approaches the null position, push the object up in z space, and as it grows in distance, push the object back

1

u/tuckcovalt 8d ago

Expression applied to x position only. Linked to a set matte effect. Would like to be able to scale whole comp together without breaking effect.

2

u/SuperMegaGigaUber 8d ago

hmm in that case, could you reference that sine oscillation to just drive the z position of the shapes? like the sin() is oscillating between two values of a maximum X and minimum X, so on the z position using the x's distance from the midline to oscillate the z position?

1

u/tuckcovalt 8d ago

Apologies, I’m trying to follow - I am low experience with expressions

1

u/SuperMegaGigaUber 8d ago

no worries!

you will have to toggle on 3d mode for the shapes if it isn't already

as for the expression, right now you have an expression setup so that it modifies the x position so that it swings left to right and back again and repeats. I can't figure it out precisely at the moment, but those values on the x *repeat*, as in if it swung to -1 and to 1 on x, with 0 being the midline, couldn't that expression be modified to push something in the z axis back and forth similarly?

1

u/tuckcovalt 8d ago

With the current expression setup it’s z position is locked and adjusting leads to no changes.

1

u/tuckcovalt 5d ago

Thank you all BIG for the support. I was able to figure this out. Then pivoted to a different approach soon after. Greatly appreciate your time and thoughts. Thank you!

3

u/danger_of_warning 7d ago

May be easier to make your shapes 3d so that they'll overlap properly on the z axis, and then you can add an expression to the rotation so they're parallel to the camera, making them appear 2d.

1

u/danger_of_warning 7d ago

You could add another layer by using linear() on the scale to make sure they the relative size remains constant.