Skip to main content
Participant
June 18, 2021
Question

After Effects Expression Help

  • June 18, 2021
  • 3 replies
  • 314 views

Hello, 

 

I am quite new to After Effects and have been following a YouTube tutorial to create an expression based VT countdown clock. I have been following the tutorial exactly and everything was working perfectly apart from one expression. When I type the below expression it says there is issues with it, first it said "expression result must be of dimension 2" in the first line which was resolved when I changed the brackets to square brackets. Now it is saying "couldn't turn result into numeric value" on the third line. Here is the expression used: 

angle=degreesToRadians[6*parseInt(name)-180];
radius=effect("radius")("Slider");
yPosition=radius*Math.cos(angle);
xPosition=radius*Math.sin(angle);
(xPosition+540,yPosition+540);

Here is the YouTube tutorial I am following: https://youtu.be/V2kraY0qeF0

Any help would be greatly appreciated!! 

This topic has been closed for replies.

3 replies

Community Expert
June 19, 2021

Dan's solution matches the sample code given on the linked doc in the YouTube description.

 

I don't think the tutorial is terrible, It's just way more complicated than it needs to be. I have several similar setups in my collection of saved animation presets for creating gauges and dials that animate automatically, but the animations are all based on the layer in and out points instead of comp length so you can it is easier to set up projects than it is to be changing comp length.

 

FYI, here's the code from the linked doc:

Expression 5 - Text Layer -> Transform -> Position

angle=degreesToRadians(6*parseInt(name)-180);
radius=effect("Radius")("Slider");
ypos=radius*Math.cos(angle);
xpos=radius*Math.sin(angle);
[xpos+540,ypos+540];

 

Dan Ebberts
Community Expert
Community Expert
June 18, 2021

You have square brackets in the first line, where you need parens, like this:

angle=degreesToRadians(6*parseInt(name)-180);
radius=effect("radius")("Slider");
yPosition=radius*Math.cos(angle);
xPosition=radius*Math.sin(angle);
[xPosition+540,yPosition+540];
Mylenium
Legend
June 18, 2021

Pretty bad tutorial, to be honest. Relying on converting a string into a numeric value while at the same time animating the text is bad practice. Instead use a slider to feed the text as well as the angle function. Saves you a whole line of superfluous code and the only extra provision on the text layer would have to be a .toFixed() or Math.round() to get rid of decimal values. Point in case: The whole setup shown in the video is designed wrongly from the ground up with regards to how expressions work in AE.

 

Mylenium