8 Replies Latest reply on Oct 8, 2016 4:57 PM by tiagoBRcastro

# Falling element stop a specific position

I found this expression here for make an object fall from its starting point simulating gravity:

seedRandom(index,true)

mGravBase=9.81; //basic gravity

mGravVar=random(-1,1); //gravity variation

mAccel=time*(mGravBase+mGravVar);

X=value[0];

Y=value[1]+Math.pow(mAccel,2);

[X,Y]

But this make the object fall forever, how can I set the last position of the animation and make it stop?

• ###### 1. Re: Falling element stop a specific position

Animate it by hand. Why even bother with an expression?

Mylenium

• ###### 2. Re: Falling element stop a specific position

I was going to say the same thing but then thought maybe they had some reason for the expression.

I tried giving it a boolean switch via an expression control effect but setting it to 0 sends the object back to it's starting point.

• ###### 3. Re: Falling element stop a specific position

I tried giving it a boolean switch via an expression control effect but setting it to 0 sends the object back to it's starting point.

Naturally so. You need to accumulate the actual values.

Mylenium

• ###### 5. Re: Falling element stop a specific position

There is a lot of objects and I would like it to seem more falling than just moving. This expression do exactly what I want, except that it do not stop moving.

This link I just discover are very useful. I will try and come back with a solution.

After Effects expression examples

EDIT : It did not worked =(

• ###### 6. Re: Falling element stop a specific position

If you want elements to accelerate like they would because of gravity and then hit a floor you need to add a position for the floor to your expression. The easiest way to do that is use an if statement that says if the layer's Y position is less than then value of the floor's y position then fall else y = the floor's y position. I'm not going to write it for your but that is the approach that will work with the least amount of fussing around.

You'll probably also want to add some bounce or squash and stretch to sell the move. Unless you have a bunch of these layers to animate I'd suggest you just keyframe by hand using the graph editor to adjust the speed.

• ###### 7. Re: Falling element stop a specific position

It would probably try (after wasting 3 hours trying to get an expression to work) creating the animation by hand on a null layer.

You just need to apply a little easeOut at the beginning to fake some acceleration & some squash & stretch if you want it to look really nice.  The pre-compose the animated null. Once it's preComped you can duplicate as many times as you need and parent whatever object you want to it and also offset the offset the timing.

You could also try creating the animation once by hand and save it as an animation preset. Then, obviously, apply the preset to whatever object you want.

There is also a plug-in called Newton that simulates physics but it costs \$250.

• ###### 8. Re: Falling element stop a specific position

After trying and experimenting for many hours I gave up. I bought a book named After effects Expressions, for learning more. Thank you all for your tips and encouraging words. I come back in the future with a good answer.