Forum Replies Created

Page 4 of 6
  • Alright- I give up. Here’s my file, without all the dependencies.

    4125_max.aep.zip

    As you can see, the rotation effect doesn’t start working until the height of the wave comp’s alpha reaches around 180px.

  • This is frustrating the heck out of me. I want to remove the comp height/width check from the code above, but I’m not sure which variables to remove or change. I keep running into errors.

  • Actually before I do that, what I just noticed is that the rotation actually works once the animation gets to a point where the waves move higher on the screen. I’ll play with this a bit more, now that I know that.

  • Ah, unfortunately they haven’t bumped us up to CS5.5 or CS6 here.

    So all the errors have gone away, but the boat’s rotation property doesn’t seem to be effected in any way. I’ve been scouring through this, rearranging variables and things to see if I can get it to work, but I can’t make sense of it enough to figure it out.

    target = thisLayer;
    targetWorldPos = target.toWorld(target.anchorPoint);
    sample = thisComp.layer("Waves");
    offset = -10;

    for (i = 0; i < 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 < 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);

  • 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 < 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 < 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);

  • Did that, but now it says “target.toWorld” is undefined. I’ve been combing through the script, and messing with this a bit, and I can’t figure it out.

  • Ah, one sec. The rotation expression you wrote is for if I were to pre-comp the boat and waves, which I’m not doing. I can’t figure out how to take that expression and make it apply to the boat layer that I already have the position expression working on.

    Is this rotation expression meant to be applied directly to the boat layer’s rotation property? Or is it meant to be applied to the wave layer, and thus targets the boat layer instead?

  • Very cool. Thanks again!

  • Actually the expression you gave me earlier works exactly the way I want. He will only be moving about halfway across the screen. Now, I just have to add the rotation expression.

    Thank you for writing this for me- I’d like to learn expressions better, but the syntax is hard for me to swallow, and I have no experience with anything similiar, such as javascript.

    How do I go about baking an expression? (if it’s too hard to explain, I’ll just google it.) Is that the same as pre-rendering a comp?

    Again, thank you!

  • That works! Amazing. Thank you SO much. My last thing I need to do is find a way to make the boat rotate slightly as it bobs, so in other words, when it bobs up the boat rocks back, and when it bobs back down, it rocks forward. Is that easy to do?

Page 4 of 6

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy