The ball (green) keeps the same X position all times, at the center of the comp, but its Y position goes up and down. At the same time, the wave shape layer (red) is moving from right to left (X position). It should looks like as the ball is always in the comp’s center, going up and dawn along the waves, and the red shape layer is moving from right to left.
I was using the following expression at ball’s Y position, but it’s very hard to connect the ball’s amplitude and frequency to the wave’s X and Y displacement.
You can adjust the Y position of the ball by testing the collision with the sine wave.
First, I tried to use sampleImage to test the collision, it worked but the rendering time was too long (more than 1 hour for a few seconds of video).
Finally, I tried in a different way, I calculated the distance between the ball and each points of the sine wave and if the distance was lower than the ball radius it means that the sine wave collide with the ball so I adjusted the ball Y position until collision return false.
I’m a beginner on JS and expressions, but I was able to understand what you did. Besides the collision stuff, you also have also created the sine path using and expression (createPath()). It is amazing. Thanks.