1

I am currently trying to create some kind of drag and drop as well as a drag and select animation in after effects. The latter one is supposed to be looking something like this in the end:

enter image description here

(this animation is from adobe themselves, showing how to make stuff pixel-perfect in illustrator and can be found here: https://helpx.adobe.com/illustrator/how-to/pixel-perfect.html)

My problem is, that (1) I have have no idea how to make an object follow the animation of another object but only for a certain time. I mean, there is parenting, but I obviously just want the object to follow my cursor-object as long as it is in "clicked state" and not during the whole animation. I hope that makes sense ...

Also (2) I have no Idea how to let an anchor point of a rectangle follow another object.

My way of doing such an animation would be animating each object independently, but it always gets messy lining those animations up, especially when I for example change the speed of one of these animations in question, because I then will have to redo all the lining up again. There has to be an easier way!

Please let me know if you either know the answer yourself or a tutorial that can help me with this.

Kind regards, Arvid

1

Expressions are you friend. Honestly I don't understand how anyone use AE without using expressions. To make the size of a rectangle shape follow a mouse you could do this.

Parent the mouse and rectangle to a null, with the top left corner of the rectangle aligned with the null. On the size property alt/option-click the stopwatch to open the expressions editor.

Delete what's there, and drag the pickwhip (the blue curly thing) to select the position of the cursor layer.

enter image description here

the size property will now look like:

thisComp.layer("cursor").transform.position

(if your cursor layer is called "cursor"). Now when you move the cursor the rectangle will scale to match the movement. But there's a problem, it scales from the middle, so you can add an offset to its position to make sure it lines up correctly. This time we use a bit of maths as well. On the position property of the rectangle path (not the position property of the layer) alt/option-click the stopwatch and drag the pickwhip to the size property of the rectangle, and then divide that value by 2. It will look like:

content("Rectangle 1").content("Rectangle Path 1").size/2

Now your rectangle should resize as if it's beign dragged by the cursor. You might have to manually drag the layer to line up perfectly. You can use more javascript to make the layer start and stop following the mouse.

Go learn expressions. As a bonus (or perhaps as a negative) you get to learn javascript, a ubiquitous computer language.

  • yeah, I also love expressions :D How would you go about making it stop? Cutting up the layer using cmd/ctrl + shift + d? Or is there something to do just that? Also the whole Null thing would mean the rectangles follow my cursor before the animation takes place? Or when I have multiple rectangles, would I have to use multiple nulls parented? Also thanks for your help! – CrazyQwert Nov 24 '16 at 10:42
  • You can use expressions to make it start and stop. For example a technique I often use is to have the expression start after the last keyframe. You do that with something like if (time>foo.bar.key(foo.bar.numkeys).time){ <whatever> } the code inside the curly braces will only get executed if the time is later than the last keyframe for the foo.bar property. – stib Nov 24 '16 at 12:46
  • You could also use another property to turn the expression on or off, e.g. a slider in an Expression Control effect: if (effect("Slider Control")("Slider") > someValue){ <whatevs> } would execute the code only when the slider value was above someValue. – stib Nov 24 '16 at 12:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.