Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

No recursive expression, right ?

New Here ,
Mar 15, 2019 Mar 15, 2019

Hi,

This expression, put in a NULL.position won't make it move. For the expression is somehow recursive :

newPosition = [] ;

if (time>1) {

    lastPosition = thisComp.layer("NULL").position.valueAtTime(time-thisComp.frameDuration);

    // filter core :

    newPosition[0] = lastPosition[0] + 10 ;

    newPosition[1] = lastPosition[1] ;

    newPosition[2] = lastPosition[2] ;

    }

else {newPosition = [960,540,0] ;}

[newPosition[0],newPosition[1],newPosition[2]  ]

Is there a workaround to create an algorithm of this sort :    position(n)  =   f(     position(n-1)    )   

Thanks !   

584
Translate
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

correct answers 1 Correct answer

Community Expert , Mar 15, 2019 Mar 15, 2019

An expression can't access a previous result using valueAtTime(). It only has access to pre-expression values. But you can often overcome this limitation by basing your calculation on time. For example, if you want the layer to move right 10 pixels on each frame, you could do something like this:

f = timeToFrames(time);

value + [f*10,0,0]

Dan

Translate
Community Expert ,
Mar 15, 2019 Mar 15, 2019

An expression can't access a previous result using valueAtTime(). It only has access to pre-expression values. But you can often overcome this limitation by basing your calculation on time. For example, if you want the layer to move right 10 pixels on each frame, you could do something like this:

f = timeToFrames(time);

value + [f*10,0,0]

Dan

Translate
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
Mentor ,
Mar 15, 2019 Mar 15, 2019

Everybody would do this with a for-loop, but this is da(m)n clever!

Translate
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
New Here ,
Mar 16, 2019 Mar 16, 2019
LATEST

Thanks Dan, Thanks Martin,

In fact, my example was purposely basic. What I needed to do was a smoothing of the motion of a NULL to animate another NULL and make it the point of interest of a camera.

I found a workaround ... which is better in fact than the original first order filter I tried to implement :

CreativeCOW

Thanks !

Translate
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