Skip to main content
Participant
November 17, 2021
Question

Can't use an old expression in After effects 2022

  • November 17, 2021
  • 2 replies
  • 476 views

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])

 

This topic has been closed for replies.

2 replies

ShiveringCactus
Community Expert
Community Expert
November 17, 2021

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.

 

Dan Ebberts
Community Expert
Community Expert
November 17, 2021

For starters, the first line should be:

layerCount = thisComp.numLayers;