Can't use an old expression in After effects 2022

New Here ,
Nov 16, 2021 Nov 16, 2021

Copy link to clipboard

Copied

I used this code a while ago with Ae2019

Now I'm trying to use in Ae2022 but it says "Couldn't turn result into numeric value"
What do I need to change?

 

This is the expression:

(line with error angle=controlAngle+offset;)

layerCount=thisComp.numbLayers;
objectCount=layerCount-thisComp.layer("Control").index;
objectIndex=index-thisComp.layer("Control").index;

radius=thisComp.layer("Control").effect("Radius")("Slider");
controlAngle=thisComp.layer("Control").effect("Caroussel Angle")("Angle");
offset=360/(objectCount)*objectIndex;
angle=controlAngle+offset;

x=radius*Math.cos(degreesToRadians(angle))
y=0;
z=radius*Math.sin(degreesToRadians(angle))
centre=thisComp.layer("Control").toWorld([0,0,0]);
add(centre,[x,y,z])

 

TOPICS
Error or problem , Expressions , How to , Scripting

Views

76

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Nov 16, 2021 Nov 16, 2021

Copy link to clipboard

Copied

For starters, the first line should be:

layerCount = thisComp.numLayers;

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Nov 17, 2021 Nov 17, 2021

Copy link to clipboard

Copied

LATEST

It's difficult to see without the fullo comp and Dan's right about the error in line 1, although that doesn't explain the issue wit the line:

angle=controlAngle+offset;

Has your project reverted to Legacy ExtendScript?  You can check this in File > project settings

 

When I'm debugging expressions, I'll create a text layer and add each line in turn to the sourcetext.  The error is suggest AE cannot get a number, so see what the code is failing to turn into a number.

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines