ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Have A Rolling Ball Dynamically React To Terrain

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Christian Magadan
Have A Rolling Ball Dynamically React To Terrain
on Mar 2, 2017 at 12:59:56 am

Say that I create a composition with a circle and "hill" (A black solid with a mask to simulate a hill in the center), and I want the ball to roll over the hill (Start at the bottom, roll up the hill, hit the crest, and then roll down the other side). My issue is that I want to be able to do this with expressions. Where I can have the ball move from the left side of the screen to the right side, and if the ball detects that it is on top of a solid, it will move up 1px and then recheck to see if it is still on the solid, if it is, it will move up 1px more and then keep checking until it is no longer on the solid. . I have gotten it so that the ball can move upwards a defined amount when it detects if it is on top of the solid using the following formula:

a=(thisComp.layer("Black Solid 5").sampleImage(transform.position,[1,1])[3]*100);
x=transform.position[0];
y=transform.position[1];
[x,y-a]

So how would I go about making that "100" value dynamic based on how many pixels the ball has to move up until its midpoint is no longer touching the "hill". Is this even possible to do in AE?

My end goal is to make it so that I can change the hill and move it around, and the ball will still roll on the surface like it's supposed to.

Thanks!


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]