Create an Interactive Text Animation with AI and Newton in After Effects

Build a dynamic text animation where layers detect and react to each other inside After Effects.

Tutorial: Create an Interactive Text Animation with AI and Newton in After Effects

Have you ever dreamed of creating animations where elements interact organically, as if they were alive? In this tutorial, we'll show you how to create a dynamic text animation where layers detect their environment and adapt their appearance in real-time.

Get our tools for Adobe After Effects : https://aescripts.com/mobo-super-suite/
Questions or feedback? Feel free to join our Discord server

To achieve this result, we'll combine the power of several cutting-edge tools:

  • A generative AI (like ChatGPT) to write complex expressions effortlessly.
  • The Newton 4 plugin for realistic physics simulation.
  • The Connect Layers Pro script to finalize our animation with lines that connect to each other.

The goal isn't to become a coding expert, but to see how to use these tools intelligently to bring your ideas to life. Let's get started!

Part 1: The Brain of the Animation - Expressions by AI

The first step is to create the logic for our animation. We will ask an AI to generate the After Effects code (expressions) that will allow our layers to "see" their neighbors.

Step 1: The Initial Prompt

Our role is to give clear instructions to the AI. To start, we'll ask it to create an expression that counts the surrounding layers within a given perimeter.

I want an expression for Adobe After Effects.
I want to put an expression on a text layer that counts the number of layers around it, within a perimeter of 300 pixels.


Step 2: AI-Assisted Debugging

The first generated code is never perfect. Our method consists of a "test-error-correction" loop:

Test the code in After Effects.
If an error appears, take a screenshot.
Send the error to the AI, which will analyze and propose a fix.

After a few back-and-forths, we get an expression that works perfectly and only counts layers of type "Text".

Step 3: Driving Properties

Now that our detection system is ready, we'll use it to animate different properties. Here are the three expressions we'll use:

The Displayed Text: The layer displays the number of neighbors, with a limit of 9.

var radius = 300;
var thisPos = thisLayer.toWorld(thisLayer.anchorPoint);
var count = 0;

for (var i = 1; i <= thisComp.numLayers; i++) {
  if (i != thisLayer.index) {
    var other = thisComp.layer(i);
    try {
      var srcText = other.text.sourceText;
      var otherPos = other.toWorld(other.anchorPoint);
      var d = length(thisPos, otherPos);
      if (d > 0.5 && d <= radius) {
        count++;
      }
    } catch (err) {
      // not a text layer — ignore
    }
  }
}

Math.min(count, 9).toString();

The Scale: The layer grows (from 25% to 150%) based on the number of neighbors.

var radius = 300;
var thisPos = thisLayer.toWorld(thisLayer.anchorPoint);
var count = 0;

for (var i = 1; i <= thisComp.numLayers; i++) {
  if (i != thisLayer.index) {
    var other = thisComp.layer(i);
    try {
      var srcText = other.text.sourceText; // throws if not a text layer
      var otherPos = other.toWorld(other.anchorPoint);
      var d = length(thisPos, otherPos);
      if (d > 0.5 && d <= radius) {
        count++;
      }
    } catch (err) {
      // skip non-text layers
    }
  }
}

// Clamp count to a maximum of 9
var clamped = Math.min(count, 9);

// Remap from 0→9 to 25→150
var scaleVal = linear(clamped, 0, 9, 25, 150);

[scaleVal, scaleVal]; // uniform scale

The Stroke: The stroke width increases with the density of layers.

var radius = 300;
var thisPos = thisLayer.toWorld(thisLayer.anchorPoint);
var count = 0;

for (var i = 1; i <= thisComp.numLayers; i++) {
  if (i != thisLayer.index) {
    var other = thisComp.layer(i);
    try {
      var srcText = other.text.sourceText;
      var otherPos = other.toWorld(other.anchorPoint);
      var d = length(thisPos, otherPos);
      if (d > 0.5 && d <= radius) {
        count++;
      }
    } catch (err) {
      // skip
    }
  }
}

// Clamp to max 9
var clamped = Math.min(count, 9);

// Remap to stroke width range: 0 → 10
linear(clamped, 0, 5, 0, 10);

Part 2: The Movement - Physics Simulation with Newton

With our logic in place, it's time to make our objects move naturally.

  1. Preparation: In After Effects, prepare a text layer with a circular mask. Temporarily disable the scale expression and duplicate the layer (in our example, about twenty times).
  2. Launching Newton: Import all your layers into Newton.
  3. Physics Settings:
    Disable gravity.
    ​​​​​Apply a magnetic repulsion force between all objects.
    Use the "Randomizer" to vary the intensity (e.g., 400-800) and distance (e.g., 150-300) of the magnetism.
    Give your objects an initial velocity so they are not motionless at the start.
    Check "Fix Rotation" in the advanced options to prevent the objects from rotating on themselves. 

 

Once satisfied, render the animation to export the keyframes back to After Effects.

Part 3: The Design - Finishing Touches with Connect Layers Pro

Our animation is now functional and fluid, but it's missing the final touch to make it visually captivating.

  1. Adjustments: Re-enable the scale expression on all layers. Adjust the stroke expression if necessary (for example, if you notice you never have more than 5 neighbors, make the maximum thickness be reached at 5).
  2. Creating the Lines:
  3. Create a Null Object in the center of the composition.
  4. Launch the Connect Layers Pro script.
  5. Select all your text layers, then the null, and click "Many to one".
  6. Styling:
    Connect Layers Pro has generated a single shape layer with all the lines. You can now control its appearance via the effects.
    Adjust the "Curviness" to Quadratic In-Out.
    Reduce the "Stroke Width" for a finer look.
    Animate the appearance of the lines with the "Trim Paths" feature.
    Apply an elegant gradient to the lines to finalize the design.

 

Conclusion

And there you have it! By combining the intelligence of an AI for the code, the power of Newton for the physics, and the efficiency of Connect Layers Pro for the design, we've created a complex animation in a simple and intuitive way.

This workflow shows that you no longer need to be an expert in code to achieve sophisticated effects. The most important thing is to have a creative vision and to know how to use the right tools to achieve it.

Feel free to experiment with these techniques. Share your creations and questions on our Discord server !