Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Position of Comp to 'Offset' (or index) position of text animator

  • Position of Comp to 'Offset' (or index) position of text animator

    Posted by Paul Ducco on February 15, 2023 at 3:34 am

    I’m wanting to position a precomp at a specific location…at the end of a text layer, as the text layer types on.

    I’ve managed to get the core functionality working…but I’d like the movement of the precomp to be effectively keyframes, not smoothly animating from one end to the other. The text types on with an opacity animator

    <i style=””>Question 2: if I reference the offset of the animator using percentage, it’s fine, if I reference using index, it breaks

    Code is below, but I’d appreciate assistance nutting an effective approach out.

    I’m sure it’s possible.

    controlLayer = effect("Typing Connection")("Layer").index;

    xPos = thisComp.layer(controlLayer).transform.position[0];

    yPos = thisComp.layer(controlLayer).transform.position[1];

    animationDriver = thisComp.layer(controlLayer).text.animator("Type").selector("Range Selector 1").offset;

    textWidth = thisComp.layer(controlLayer).sourceRectAtTime().width

    textStart = animationDriver.key(1).time;

    textFinish = animationDriver.key(animationDriver.numKeys).time;

    typePos = linear(time, textStart, textFinish, xPos, xPos+textWidth);

    [typePos, yPos]

    Paul Ducco replied 3 years, 2 months ago 3 Members · 14 Replies
  • 14 Replies
  • Paul Ducco

    February 15, 2023 at 10:34 pm

    Development: managed to get this kinda working a bit better, using indexes and rounding to ensure full numbers…however it isn’t perfect for all character width. That said, it’s progress.

    I’m now wondering if there’s a way to set a key for the position of the precomp. Currently, because it is being repositioned by an expression, the values aren’t ‘true’ values…and in an ideal world this expression (of following the position of the typing text) would work in combination with the ability to keyframe the position of the precomp as well.

    Hope this makes sense. Am I asking too much (again :))

  • Dan Ebberts

    February 15, 2023 at 10:38 pm

    There’s always Animation > Keyframe Assistant > Convert Expression to Keyframes (after selecting the property with the expression).

  • Paul Ducco

    February 15, 2023 at 10:47 pm

    Well that’s news to me too!
    Yeah cool…that might work, except the text often changes at the last minute, so might cause more headaches than I was trying to solve.

    Thanks again Dan, as always, your knowledge and input is above and beyond

  • Filip Vandueren

    February 16, 2023 at 8:22 am

    Is this to dynamically position a custom cursor for a type in effect? Can you elaborate a bit on what the result needs to be ?

    Is it only on 1 line text, or can it be multi line paragraph text too?

  • Paul Ducco

    February 16, 2023 at 10:48 pm

    Yup! You nailed the usage…BUT…it’d need to be animated (with keyframes) ‘to’ the beginning point of text, and then ‘from’ then end point of the text. It would be amazing if it could cover multiple lines…but a single line would be extremely useful.

    Thanks for your input and idea bouncing 🙂
    hope the above makes sense.

  • Filip Vandueren

    February 17, 2023 at 8:54 am

    Hi Paul, something like this:

    https://imgur.com/a/SkZuL2D

    It’s based on subSourceRect, and more or less uses the position of the last visible letter in a Null, the cursor is then parented to thenull so it can have its own relative keyframes (at start and end)

    The motion of the Null is controlled automatically by the opacity text-animator.

    There’s a lot of different moving parts and little expressions that don’ make a lot of sense on their own to control text-animators, so posting the code will be just confusing, but here’s the projectfile:

    https://we.tl/t-t4LRGmHPgf

    View post on imgur.com

  • Paul Ducco

    February 18, 2023 at 2:51 am

    That is mind blowing. You are mind blowing. Thanks Filip.

    I’ll have a proper look, but may borrow this structure and implement it with the null being an invisible shape layer. It is a rather complex build already with the base cursor variations being all contained as shape layer.

    Thanks again

  • Paul Ducco

    February 18, 2023 at 3:04 am

    In wanting to extend my knowledge, if you’re open to it I’d love to ask you a couple of questions regarding the set up. Things like, is the Point Controller used as an easier way ‘toComp’ the values?
    Yell out if you’re open to it, and whether we do so here, or an an IM platform.

    Thanks again Filip. So great.

  • Filip Vandueren

    February 18, 2023 at 8:05 am

    hi Paul,

    the Point Control can be omitted, the expression there could have been added directly to he position of the Null. But in that case all of the implied/omitted thisLayer.s of the expression’s properties need to be spelled out as a property of the textLyaer, and I found it more convenient to have the “leading edge position” of the text to be a property on the text layer itself.

    When applied directly to the Null, it would become:

    txtL = thisComp.layer("txt");

    i = txtL.text.animator("Animate On (opacity)").selector("Range Selector 1").start.value;

    // length of sourcetext excluding linebreaks and softbreaks;

    l = txtL.text.sourceText.replace(/\n|\r|\3/g,"").length;

    if (txtL.text.animator("Animate On (opacity)").selector("Range Selector 1").advanced.units.value==1) {

    // convert from percentage to index

    i = i*l/100;

    }

    i=Math.round(i);

    if (i==l) i--; // never exceed the last character !

    sr = txtL.sourceRectAtTime(-100-i);

    txtL.toComp([sr.left, sr.top+sr.height/2]);

    But I’d keep it on the textLayer personally.

    Conceivably, you could even have the cursor jump from the end of 1 completed text-layer to the start of the next by adding some code in the Null to interpolate between different pointControls on different textlayers.

    But you’re very correct in noting that a point control on a text layer (as on all continuosly rasterized layers) is always in Comp space.

  • Filip Vandueren

    February 18, 2023 at 8:32 am

    oh Btw:

    Some fonts have different widths for their regular space, so sometimes you will want to replace the spaces with a different unicode spacer that’s closer.

    Here’s a list of possible characters, not all of them work (the cursor would then go to 0,0 everytime inencounters a space) so I’d stick to the range \u2004 – \u2009

    https://www.compart.com/en/unicode/category/Zs

Page 1 of 2

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