Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Creating text animation .mogrt template

  • Creating text animation .mogrt template

    Posted by Amy Sak on January 22, 2024 at 2:54 pm

    Hello everyone. I’d like to pick your brain please.

    I want to create a .mogrt template that allows people to make a customizable text animation like this attached clip. My aim is when people type any words or sentences, the gray background box will expand automatically according to the length of the text, and the blue line animation will also follow the gray box – meaning X position movement distance will be the width of the gray box (hope this makes sense).

    So far, I’ve managed to make the gray box to be automatically expanded based on the length of the text using “sourceRectAtTime” expression.

    Now, I’m stuck at the next step which is to make the blue line move from the left end of the gray box to the right end. I’m assuming that I need to write some magical code in X position to make the moving distance to be the same length as the gray box width, but I have no idea what to do.

    I attached a screenshots of the layers, keyframes and expressions for your reference.

    I’m a beginner so I appreciate if you can guide me step by step with easy language. Thanks in advance!

    Amy

    Roland R. kahlenberg replied 4 months, 4 weeks ago 4 Members · 9 Replies
  • 9 Replies
  • Roland R. kahlenberg

    January 22, 2024 at 5:38 pm

    As it is in AE, there are a couple of ways to do this. I’d look at using the Linear Interpolation Expression Method. So, look into that to see if you’re able to to achieve what you want.

    I’m actually having a hard time looking at your code cos everything’s so tiny.

    Stuff like this looks easy but they involve combining different mid to difficult aspects on Expressions and can get complicated once you add more Text Layers into the mix. I’d put this at Intermediate Level AE and not ideal for a newbie unless you have the patience to dig deep and far.

    If you can post your code in your post, it will be more useful to other to see it as well as to edit it, to provide you with perhaps clearer guidance.

  • Hector Vera

    January 22, 2024 at 6:12 pm

    Below the blue line section where it says Path, I am not seeing the X and Y axis values there but if you wish for you to move the blue line from left to right, I suggest that you try to create simple two keyframes, the first one where the X axis is positioned all the way from the left and the 2nd one where its all the way to the right. Not sure why there are multiple keyframes there but you may want to simplify it to just 2 keyframes first to test positions. You can set it in a specific timeline for how long you wish for the blue line moves from left to right in the x axis. Hope it helps and best of luck! 🙂

  • Amy Sak

    January 23, 2024 at 1:44 am

    Thanks for your reply Roland.

    I wasn’t sure how difficult it was to achieve this so it’s good to know that it is a complicated one (so I’m not too hopeless)!

    I’m happy to dig deep as this won’t be a one off project for me and I’ll need to be able to make .mogrt templates out of motion graphics I designed. I’ve been hating to compromise my design due to lack of knowledge/skill of writing expressions to convert them into .mogrt…

    Anyways, here are the codes. Please let me know what you think. I’m not looking into Linear Interpolation Expression Method that you suggested. Thanks again.

    Rectangle Path – Size

    var s = thisComp.layer(“text here:)”);

    var start = s.inPoint;

    var end = s.outPoint;

    var mid = (end-start)/2;

    var w = s.sourceRectAtTime(mid).width;

    var h = s.sourceRectAtTime(mid).height;

    [w,h];

    Rectangle Path – Position

    var s = thisComp.layer(“text here:)”);

    var start = s.inPoint;

    var end = s.outPoint;

    var mid = (end-start)/2;

    var w = s.sourceRectAtTime(mid).width/2;

    var h = s.sourceRectAtTime(mid).height/2;

    var t = s.sourceRectAtTime(mid).top;

    var l = s.sourceRectAtTime(mid).left;

    [w+l,h+t];

    Transform: Rectangle 1 – Anchor Point

    var s = thisComp.layer(“text here:)”);

    var start = s.inPoint;

    var end = s.outPoint;

    var mid = (end-start)/2;

    var t = s.sourceRectAtTime(mid).top;

    var l = s.sourceRectAtTime(mid).left;

    var o = content(“Offset Paths 1”).amount;

    [l-o, t-o]

    Transform: Rectangle 1 – Position

    content(“Rectangle 1”).transform.anchorPoint

  • Amy Sak

    January 23, 2024 at 2:35 am

    Thanks for your reply Hector.

    The key frames under “path” is for the dot becomes the line before it starts moving in X axis. My question isn’t how to animate the blue line, it’s about how I can write codes so the movement distance of the blue line will be automatically calculated and adjusted based on the length of the text for creating .mogrt template. If you know how to do it, please assist me! Thanks!

  • Amy Sak

    January 23, 2024 at 2:36 am

    Thanks for your reply Hector.

    The key frames under “path” is for the dot becomes the line before it starts moving in X axis. My question isn’t how to animate the blue line, it’s about how I can write codes so the movement distance of the blue line will be automatically calculated and adjusted based on the length of the text for creating .mogrt template. If you know how to do it, please assist me! Thanks!

  • Amy Sak

    January 23, 2024 at 4:53 am

    Hi Roland,

    In my earlier reply, I wanted to write I’m “NOW” looking into Linear Interpolation Expression Method as you suggested, not I’m “NOT” looking into. Sorry for the typo😑

  • Roland R. kahlenberg

    January 23, 2024 at 6:08 am

    No worries I did take note of the typo.

    BTW, AE comes pre-installed with two Animation Presets that handle part of the solution –

    2D Text Box and Lock Anchor Point

    I am also in the midst of designing courses that cover this sort of issues.
    https://www.broadcastgems.com/post/advanced-after-effects-courses-coming-up-soon

  • Tom Morton

    January 23, 2024 at 7:24 am

    Hello Amy,

    One of my most-used expressions for this sort of things is the “linear()” expression. Here’s the Adobe ref guide on it: https://helpx.adobe.com/after-effects/using/expression-language-reference.html#:~:text=Interpolation%20methods%20(expression,range%20of%20values.

    But here’s some quick and simple ideas. If you write this in the position property of an object:

    x = linear(time, 0, 3, 10, 200);
    [x, 0]

    This will make the object move from position 10 to position 200 in between 0 and 3 seconds on the X axis.

    And then you can use variables to make sure the positions and timings are correct:

    var s = thisComp.layer(“text here:)”);

    var start = s.inPoint;

    var end = s.outPoint;
    var mid = (end-start)/2;
    var w = s.sourceRectAtTime(mid).width/2;
    var h = s.sourceRectAtTime(mid).height/2;
    var t = s.sourceRectAtTime(mid).top;
    var l = s.sourceRectAtTime(mid).left;


    x = linear(time, start, end, l, w);
    y = h+t;
    [x, y];

    I’m not 100% sure that will work correctly for you, I haven’t tested it, but that might give you an idea of how to work it.

    As you continue to build this, you could also use the “Trim paths” effect to grow the line down and up, and when you do this you can also use the linear() expression to grow the line.

    Hope that helps and shout if there’s anything you don’t understand on this! I’ve built a few things like this, so if you want to share what you’ve done at any time I’d be happy to comment! I’m a big fan of templating things properly so I lean on Afx fairly heavily.


  • Roland R. kahlenberg

    January 23, 2024 at 1:19 pm

    If anyone is keen to take a look at samples using Adaptive & Responsive Motion Graphics, here’s my Youtube Playlist.

    Adaptive pertains to how a single MoGRT is able to work in different Frame Sizes and Aspect Ratios. Responsive features cover lots of areas and use-cases but is generally seen as the ability for elements/properties to respond to changes to Text and Visuals by the user.

    https://www.youtube.com/playlist?list=PLTVytW_35OIHRy3iFmQfmzzu9Cwj-vfg_

    Some contents or functionalities here are not available due to your cookie preferences!

    This happens because the functionality/content marked as “Google Youtube” uses cookies that you choosed to keep disabled. In order to view this content or use this functionality, please enable cookies: click here to open your cookie preferences.

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