FORUMS TUTORIALS FEATURES VIDEOS PODCASTS EVENTS SERVICES JOBS NEWSLETTER NEWS BLOGS
 ADOBE AFTER EFFECTS: Home Forum Basics Expressions Tutorials Podcasts AE Techniques Creative Cloud Debate FAQ

# Re: Expression to make a boat "ride" on top of generated waves?

COW Forums : Adobe After Effects Expressions

 Re: Expression to make a boat "ride" on top of generated waves?by Max Palmer on May 11, 2012 at 3:49:01 pm

This is how I have it. All I did was change the target, and sample variables.

`target = transform.rotation; targetWorldPos = target.toWorld(target.anchorPoint); sample = thisComp.layer("Waves"); offset = -10; for (i = 0; i &lt; height; i++){ if (sample.sampleImage([clamp(targetWorldPos[0]+offset,0,thisComp.width), i], [0.5, 0.5], true)[3] > 0){ top = [0,i]; break; } else { top = [0,thisComp.height]; } } newWorldPos = target.fromWorld(target.toWorld(top)); offsetPos = [target.position[0]+offset,newWorldPos[1]]; for (i = 0; i &lt; height; i++){ if (sample.sampleImage([clamp(targetWorldPos[0],0,thisComp.width), i], [0.5, 0.5], true)[3] > 0){ top = [0,i]; break; } else { top = [0,thisComp.height]; } } targetWorldPos = target.fromWorld(target.toWorld(top)); boatPos = [target.position[0],targetWorldPos[1]]; radians = Math.atan2(boatPos[1] - offsetPos[1],boatPos[0] - offsetPos[0]); radiansToDegrees(radians);`