Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Auto-orient along path doesn’t work when there’s a Position expression

  • Auto-orient along path doesn’t work when there’s a Position expression

    Posted by Noel Powell on February 18, 2016 at 9:13 pm

    Hi,

    I’m encountering what seems to be a bug and I’m wondering if anyone else has run into it and if there are any known solutions. It’s different from the known “flipping” problems that I’ve been reading about.

    I have a layer with keyframes on the Position to have it move. I’ve oriented the layer along the motion path using the Transform/Auto-Orient/Orient Along Path feature. It works fine until the layer gets to the last keyframe, and then it stops auto-orienting. I was able to narrow down the problem to an expression on the Position property. It seems that any expression on the Position property will cause Auto-orient along path to stop working after the last keyframe of the motion path. It doesn’t matter what the expression says – it can even just say “value”. I’ve done this in CS5 and CC2015 with the same results.

    Any ideas? I do need the expression there (I can’t use the Transform effect).
    Thanks in advance.

    After Effects Templates – digital glitch effects, 80s VHS effects, old film effects, art effects, and more: https://CreationEffects.com

    Matthias Stoll replied 4 years, 12 months ago 4 Members · 12 Replies
  • 12 Replies
  • Dan Ebberts

    February 18, 2016 at 9:26 pm

    Just curious–what’s the expression?

    Dan

  • Noel Powell

    February 18, 2016 at 9:38 pm

    The short answer is it’s a wiggle expression. It’s actually a wiggle expression within an if/else statement. The layer is 3D and the expression makes the layer wiggle in three dimensions as it moves along the path, which also twists and turns in three dimension. And even when the layer wiggles off the path, it still stays oriented to the next keyframe, which I like.
    However, as soon as it reaches the last keyframe, it stops orienting. I’ve done simplified tests with the same results. I made the layer 2d, and tried just animating it to move across the screen, with just 2 keyframes. It still goes back to its original orientation at the end of the animation.

    After Effects Templates – digital glitch effects, 80s VHS effects, old film effects, art effects, and more: https://CreationEffects.com

  • Noel Powell

    February 18, 2016 at 9:40 pm

    The short answer is it’s a wiggle expression. It’s actually a wiggle expression within an if/else statement. The layer is 3D and the expression makes the layer wiggle in three dimensions as it moves along the path, which also twists and turns in three dimension. And even when the layer wiggles off the path, it still stays oriented to the next keyframe, which I like.
    However, as soon as it reaches the last keyframe, it stops orienting. I’ve done simplified tests with the same results. I made the layer 2d, and tried just animating it to move across the screen, with just 2 keyframes. It still goes back to its original orientation at the end of the animation. It seems to do this no matter what I change the expression to. And if I take the expression out completely, it works fine.

    After Effects Templates – digital glitch effects, 80s VHS effects, old film effects, art effects, and more: https://CreationEffects.com

  • Dan Ebberts

    February 18, 2016 at 9:43 pm

    It might be very helpful to see the exact expression.

    Dan

  • Noel Powell

    February 18, 2016 at 9:48 pm

    …Sorry for the double post.

    And sure, here’s the expression:

    if (effect(“Turn on Automatic Wing Flapping”)(“Checkbox”)==1)
    { wiggle(effect(“Position Wiggle Speed (times per sec)”)(“Slider”),effect(“Position Wiggle Amount (in pixels)”)(“Slider”)) }
    else
    { value }

    After Effects Templates – digital glitch effects, 80s VHS effects, old film effects, art effects, and more: https://CreationEffects.com

  • Dan Ebberts

    February 18, 2016 at 10:20 pm

    That’s interesting. One thing you could try is turning off Auto-Orient and instead using an orientation expression like this:


    t = position.key(position.numKeys).time;
    if (time < t)
    lookAt(position,position + normalize(position.velocity))
    else
    lookAt(position,position + normalize(position.velocityAtTime(t-.001)))

    Dan

  • Noel Powell

    February 18, 2016 at 10:44 pm

    Dan, that seems to work perfectly. Thank you so much.

    I’m curious, did you run any tests and see what I was talking about? I’m considering reporting the bug.

    After Effects Templates – digital glitch effects, 80s VHS effects, old film effects, art effects, and more: https://CreationEffects.com

  • Dan Ebberts

    February 18, 2016 at 10:53 pm

    >did you run any tests

    I did. It looks like it could be a bug. I’d say go ahead an report it.

    Dan

  • Tolga Sayan

    December 8, 2017 at 4:09 pm

    Hi Kevin, Hi Dan..

    I really need your help..I am a new in scripts and I have spend minimum 12 hours undertsanding this very useful script that Kevin I guess has written… I have found it in VC forum…

    I need help in Auto orienting the car when car’s Y axis changes..

    Here is the AEP file,

    https://www.dropbox.com/s/dmqygnye8fctnja/MaxWheel_Car.aep?dl=0

    Best,

    Tolga / Turkey

  • Matthias Stoll

    January 19, 2020 at 2:31 pm

    Hi Dan, hi everybody,

    I just found out about the pointOnPath expression. It gives you any point on a path based on a percentage value. Of course, this is very powerful because you can change or even animate the motion path while your objects keep aligned to it. (In my opinion pasting path information onto an objects position is not helpful when you need to align many objects or be able to do quick adjustments. And animate the motion path is impossible)

    “auto-orient” does work, but as soon there is no animation it snaps to a seemingly random orientation. (before and after the animation)

    In this example I use a slider as input to animate the percentage value. But this is not related, whenever there is no movement on the layer, it snaps. I would simply like to copy the first and last “auto-orient” values when there is no animation. Is it possible to replace “auto-orient” with an expression which does the trick?

    L=thisComp.layer(“Shape Layer 1”);
    p=L.content(“Rectangle 1”).content(“Path 1”).path;
    p.pointOnPath(effect(“Slider Control”)(1),time)+L.position

    Help would be much appreciated, I have tons of ideas how I could make use of this.

Page 1 of 2

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