-
Position increment
Hello,
I come to ask for help for the following subject:I made a composition with a ball, an imaginary line (x = 250) and a counter.
The principle is as follows : the counter counts the number of frames when the ball is on the left.
The counter stops when the ball is on the right and continues to counting when it returns to the left.It looks like that :
And here is the code of the counter, it works perfectly :
balle = thisComp.layer("Balle");
compteur =0;for (i = 0; i <= timeToFrames(time); i++)
{
if (balle.transform.position.valueAtTime(framesToTime(i))[0]<=250)
{
compteur++;}
}
compteurNow I would like to animate the counter’s position and ask him to go up 1 pixel (so down the Y position) as soon as he counts a frame. Here is the code that I entered on the same logic of the first and based only on the counter and not on the ball :
pY = effect("Nombres")("Position")[1];
valeurAvant = effect("Nombres")("Valeur/Décalage/Maxi aléatoire").valueAtTime(framesToTime(timeToFrames(time)-1));
valeur = effect("Nombres")("Valeur/Décalage/Maxi aléatoire").valueAtTime(time);
ecart = valeur-valeurAvant;
marche = -1;for (i= 0; i <= timeToFrames(time); i++)
{
if (ecart==1){
pY = effect("Nombres")("Position").valueAtTime(framesToTime(i))[1] + marche ;
}}
[value[0],pY]
This code doesn’t work and I have almost tried everything (I say almost because there is a solution that I didn’t find …).
I try to:- Put the variables in the loop, it does not work.
- Debugging each variable in separate text layers and they seem to work
- To insert this code and to adapt it in a dissociated position, it does not work.
Well, it’s been a few days that I drool before this code but nothing works. ????
If anyone would be able to tell me where it’s wrong … ????
Thank you !
