Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Move object along an angle?

  • Dan Ebberts

    September 30, 2014 at 8:14 pm

    Something like this:

    spd = effect(“Slider Control”)(“Slider”);
    angle = effect(“Angle Control”)(“Angle”)-90;
    d = spd*(time-inPoint);
    r = degreesToRadians(angle);
    x = d*Math.cos(r);
    y = d*Math.sin(r);
    value + [x,y]

    You probably won’t get what you expect if you try and animate either of the controls but it should work with static values.

    Dan

  • Ryan Paterson

    September 30, 2014 at 10:39 pm

    That’s the one! Ok so follow-up question, and I don’t even know if this is possible but, is there a way to move the object on an angle over a period of time, then have it stop, change the angle, and then move in that direction?

    So it would basically behave as if you were keyframing with easy-ease keyframes. When it stops, it picks a new direction and goes there.

  • Dan Ebberts

    September 30, 2014 at 11:26 pm

    Possible, but not simple. You basically have to set up a loop that recalculates everything that has happened since the layer’s in point, up to the current frame, because an expression has no way to keep track of calculation results from previous frames. You also have the issue of what to do if the random angle takes the layer out of the comp view. A bit of work, but do-able.

    A somewhat easier alternative would be, on a periodic basis, to pick a new target destination within the comp boundaries. You’d still get the random angles, but the speed would vary from one movement to the next.

    Dan

  • Ryan Paterson

    September 30, 2014 at 11:35 pm

    Right. I saw your post on motionscript about random movement on a grid, but the project im doing is isometric-ish with everything moving on 60 degree angles, so not sure how that would work.

    So I’ll just use nulls to control for now, because if you say it’s hard then I literally can’t fathom what that must entail

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