Max Palmer
Forum Replies Created
-
Max Palmer
May 11, 2012 at 6:25 pm in reply to: Expression to make a boat “ride” on top of generated waves?Alright- I give up. Here’s my file, without all the dependencies.
As you can see, the rotation effect doesn’t start working until the height of the wave comp’s alpha reaches around 180px.
-
Max Palmer
May 11, 2012 at 5:28 pm in reply to: Expression to make a boat “ride” on top of generated waves?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.
-
Max Palmer
May 11, 2012 at 4:37 pm in reply to: Expression to make a boat “ride” on top of generated waves?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.
-
Max Palmer
May 11, 2012 at 4:22 pm in reply to: Expression to make a boat “ride” on top of generated waves?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); -
Max Palmer
May 11, 2012 at 3:49 pm in reply to: Expression to make a boat “ride” on top of generated waves?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); -
Max Palmer
May 11, 2012 at 3:43 pm in reply to: Expression to make a boat “ride” on top of generated waves?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.
-
Max Palmer
May 11, 2012 at 2:00 pm in reply to: Expression to make a boat “ride” on top of generated waves?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?
-
Max Palmer
May 11, 2012 at 1:51 pm in reply to: Expression to make a boat “ride” on top of generated waves?Very cool. Thanks again!
-
Max Palmer
May 11, 2012 at 1:38 pm in reply to: Expression to make a boat “ride” on top of generated waves?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!
-
Max Palmer
May 11, 2012 at 1:00 pm in reply to: Expression to make a boat “ride” on top of generated waves?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?