Adobe After Effects Forum
Attach object to moving path
Attach object to moving path
by Albert Kowalski on Aug 1, 2019 at 10:17:52 am

Hi!

I read couple of similar topics, but none of those answered my question. It goes like this:

I got an object - a ship.swf exported from Animate. This ship is naturally floating on the ocean (Postion Y is wiggling and Rotation is wiggling).
It also moves along the X swimming through ocean.
Now I want to attach a wave to the ship so its front is attached to the edge of the ship. Parenting the wave layer to the ship layer doesn't work.
The wave itself shouldn't rotate and change it's Y position. So I only attached X position to the ship so it follows the ship nicely while it swim through the ocean.

But since the ship wiggle on the Y and rotate, the waves contantly shifts on the X several pixels from the edge of the ship.
Now I manually keyframe the X position of the wave, but it's a lot of work and I'm looking for a way to automate this? Any ideas? Thanks! ☺




Re: Attach object to moving path
by Tomas Bumbulevičius on Aug 1, 2019 at 1:09:34 pm

Hey Albert, while I am not familiar with Animate - could you specify whether after exporting, you still got those transform props values accessible in AE in the native to AE, manner? OR, you made these transformations in AE already?

On a different note, when ship rotates - where its anchor point is originally based, bottom center or anywhere else?

Find out more:
After Effects Tutorials: motion design, expressions, scripting.
Boxer - Dynamic Text Boxes Template with a Live Preview



Re: Attach object to moving path
by Albert Kowalski on Aug 1, 2019 at 1:20:20 pm

Hi!

This SWF is just a still vector image, nothig else. I do every transformation in AE. Anchor point of the ship is in the bottom center.


Re: Attach object to moving path
by Tomas Bumbulevičius on Aug 1, 2019 at 1:29:44 pm

Got it, now it makes totally sense, thanks.

1. To make wave 'to ignore' rotation, link its rotation to the ship rotation, and add minus in front. It will re-translate it to 0. (Might need to adjust position of wave's anchor point though)
2. I don't 100% grasp the movement of Y axis. If you parent wave to ships X, what influence it can have from Y movement? I guess this is solely because of point nr 1 - which, once solved, should get rid of this issue.

Find out more:
After Effects Tutorials: motion design, expressions, scripting.
Boxer - Dynamic Text Boxes Template with a Live Preview



Re: Attach object to moving path
by Albert Kowalski on Aug 1, 2019 at 1:58:58 pm

The rotation parenting is not a problem. I just don't parent rotation of the wave to the ship.
Think about how it works in a real world. When a small ship is swimming it sways in the water. This movement include rotation around its anchor point (which is in the center bottom) and dipping on the Y axis. Of course the ship also move along the X axis. All this happens when we look at the ship from the side.

Look here, at the bottom ship: https://www.dropbox.com/s/wk6sozfoyf1igeb/ship.mp4?dl=0

The wave is not keyframed yet, so you can see how it shifts from the ship's edge.


Re: Attach object to moving path
by Tomas Bumbulevičius on Aug 1, 2019 at 2:08:45 pm

Thanks, seeing it helps.

Based on this, I assume wave should move back and forth in X axis, along rotation.

Maybe, in order to achieve this, you could add/subtract x shifting by interpolating rotation to to horizontal translation. Somewhat along those lines, applied to xPos.

xShift = linear(rotationProp, rotationMin, rotationMax, -xOffset, +xOffset);
transform.xPosition + xShift


Once this works as expected, in the same fashion you could introduce Y pos change.

Find out more:
After Effects Tutorials: motion design, expressions, scripting.
Boxer - Dynamic Text Boxes Template with a Live Preview



Re: Attach object to moving path
by Albert Kowalski on Aug 1, 2019 at 2:18:04 pm

Thanks. I am not an expert on scripting, so I just pasted your code to X Position of my wave, but it gives an error:

Expression disabled. Error at line 1 in property "X Position" of layer 9 ('wave') in comp 'ship'. property or method named 'rotationProp' in Class 'global" is missing or does not exist.


Re: Attach object to moving path
by Tomas Bumbulevičius on Aug 1, 2019 at 2:23:06 pm

Sorry, that was just a logical sequence, not an actual expression to be applied.

With that said:

rotationProp - expression to your ship's rotation property
rotationMin - smallest rotation value it gets
rotationMax - highest rotation value
xOffset - number of pixels the ship shall move

Explore how linear() works, here

Hope that helps!

Find out more:
After Effects Tutorials: motion design, expressions, scripting.
Boxer - Dynamic Text Boxes Template with a Live Preview



Re: Attach object to moving path
by Albert Kowalski on Aug 1, 2019 at 8:38:53 pm

Well, it doesn't work how it suppose to. The main thing in my opinion is to tell AE how the edge of the ship looks like. Cause right know it's just some vector image that cannot be interpret. Something tells me that it would be easier if I'd draw a shape where the edge of the ship is. This shape would be parented to the ship and then maybe somehow it would be possible to attach the wave to this shape? The wave would be locked in Y axis and only moved on X axis but always within the shape range.

Basically I'm thinking about it this way: object follows path only when the path is moving and only on path Y axis.


Re: Attach object to moving path
by Albert Kowalski on Aug 3, 2019 at 7:24:02 pm

Found this thread, that had a similar problem. I posted my idea at the end. Now I'm pretty sure I'll be able to solve this if my wave would follow the intersection of two lines (one line would be a path drawn on the edge of the ship and parented to the ship, and the second line would be drawn on the edge of a matte solid where the ship meets the water and also parented to this solid). If only I would be able to re-write the code to my needs...

https://forums.creativecow.net/thread/227/21403





© CreativeCOW.net