A DEBUG INSANITY …
… well, I have been trying to solve this for a few hours. What I see is beyond my (poor) understanding of AE.
I wrote my expression using this simple filtering algorithm :
newPositionB = previousPositionB + 0.2*(positionA – previousPositionB)
This way B follows A (more) smoothly.
The result I get is almost satisfying, visually. But I checked the value : there is a little error.
So I pasted my expression in a text layer to debug … and this is crazy :
The values calculated in the debug text are right … but they are not applied to B’s position.
Debug text gives me for instance newPosition[0] = 977 but B is at 968 …
Moreover, in B’s expression, I tested all the intermediary variables (lastPosition, targetPosition ) by affecting them to the first coordinate … and it is consistent with the debug text. ONLY, newPosition … which is calculated from the others remains erroneous …
So I really don’t understand …
Does any body have an idea ? … to save my soul before it blows out.
Thanks !
// expression for B's position
targetPosition = thisComp.layer("NULL--All-In-A-Frame").transform.position.value;
smoothCoeff = thisComp.layer("Curseurs---->").effect("smoothCoeff")("Slider").value/100 ;
newPosition = [0,0,0] ;
if (time>0) {
lastPosition = thisComp.layer("NULL-filtered").position.valueAtTime(time-thisComp.frameDuration);
// filter core :
newPosition[0] = lastPosition[0] + smoothCoeff*(targetPosition[0] - lastPosition[0]) ;
newPosition[1] = lastPosition[1] + smoothCoeff*(targetPosition[1] - lastPosition[1]) ;
newPosition[2] = lastPosition[2] + smoothCoeff*(targetPosition[2] - lastPosition[2]) ;
}
else {newPosition = targetPosition.slice() ;}
[newPosition[0],newPosition[1] ,newPosition[2] ]
--------------------------------------------------------------------------------------
// Expression for debug text
targetPosition = thisComp.layer("NULL--All-In-A-Frame").transform.position.value;
smoothCoeff = thisComp.layer("Curseurs---->").effect("smoothCoeff")("Slider").value/100 ;
newPosition = [0,0,0] ;
if (time>0) {
lastPosition = thisComp.layer("NULL-filtered").position.valueAtTime(time-thisComp.frameDuration);
// filter core :
newPosition[0] = lastPosition[0] + smoothCoeff*(targetPosition[0] - lastPosition[0]) ;
newPosition[1] = lastPosition[1] + smoothCoeff*(targetPosition[1] - lastPosition[1]) ;
newPosition[2] = lastPosition[2] + smoothCoeff*(targetPosition[2] - lastPosition[2]) ;
}
else {newPosition = targetPosition.slice() ;}
"last Position = " + lastPosition + "\n targetPosition = " + targetPosition + "\n newPosition = " + newPosition