Whether you’re drawing a line between two points, underlining some text, or creating a simple lightsaber effect, knowing how to animate a line in After Effects is one of the basic skills you need in your motion design toolbox.
In this article, we’ll look at perhaps the most common line animation After Effects is great for: animating a line so that it appears to draw on the screen from one point to the next.
Alternatively, you may want to check out our other blog post on how to connect objects with lines in After Effects which produces a different type of line animation - in that post the line is animated by moving the individual points on it. For this article though let’s see:
How to animate a line drawing on-screen in After Effects:
Step 1. Create a shape layer with a stroke
To get started then, first you need to draw the line you want to animate. To do that create a new shape layer by choosing
Layer > New > Shape Layer
With the new shape layer selected, you should now see the fill and stroke options appear in the top bar of After Effects. For this example, we don’t want the shape layer to have a fill effect so in the top bar click the blue Fill link to open up the fill options, then choose none (the furthest left option), and click OK.
Next, make sure the shape layer has a stroke applied to it by clicking the px value next to the stroke colour option in the top bar of After Effects, for this example let’s use a value of 10 pixels. You can also change the colour of the stroke by clicking the colour box next to the pixel value in the top bar.
Step 2. Create your line
With your shape layer selected, it’s time to create the line. To do that you need to select the pen tool from the top toolbar, or alternatively press G on the keyboard to switch to the pen tool.
Next, click on the composition window to add new points to your line, holding down the shift button will ensure that any lines you draw are straight and they’ll either be horizontal, vertical, or at 45 degrees from the previous point.
With your line now created, it’s time to animate it!
Step 3. Add the trim paths option
In the layer panel, open up the shape layer by clicking the little arrow next to the blue square, this reveals the Contents and Transform options of the shape layer.
Alongside the Contents line, you should see the Add option with an arrow inside a circle, click this arrow and choose Trim Paths from the pop-up menu.
Step 4. Add your keyframes to animate the line
Open up the trim paths settings in your shape layer by clicking the little arrow next to “Trim Paths 1” - you should see four options: Start, End, Offset, and Trim Multiple Shapes.
The option we’re interested in is the End value, which by default is set to 100%.
First, move the timeline marker to where you’d like your line animation to begin, for this example we’ll just use the starting time of 0.
Next, click the little stopwatch next to the End value to add a keyframe in the timeline.
Without moving the timeline marker, change the End value to 0% - you should notice that the stroke on your line has now disappeared.
Move the timeline marker along around 4 seconds or so (or however long you want the line animation to last) and then change the End value again to 100% - and there we are, it’s this change in the end value from 0% to 100% that creates the line animation.
And that’s it!
That’s how to create a simple line animation in After Effects, you should definitely experiment with the animating the other Trim Paths options too - for example, try keyframing the Start value from 0% to 100% in the same way as you’ve animated the End value but then shift the start keyframes over by a couple of frames, this will create a shorter line that animates along the path and disappears at the end.