Skip to main content
Inspiring
January 1, 2023
Answered

Expression freezes After Effects

  • January 1, 2023
  • 1 reply
  • 441 views

Hey guys. Maybe a silly question, but I want to make an expression that is gonna calculate object's position every frame. But for some reason with this loop After Effects freezes compeletly. What may actually cause this problem?

gravity = thisComp.layer("controller").effect("gravity")("Slider");
projectile = transform.position;
	px = projectile[0];
	py = projectile[1];
anchor = thisComp.layer("anchor").transform.position;
	ax = anchor[0];
	ay = anchor[1];
currentFrame = 	Math.round((time - inPoint) / thisComp.frameDuration);
for(i = 0; i = currentFrame; i++){
	px += 5
}
[px,py]

 

This topic has been closed for replies.
Correct answer Dan Ebberts

It doesn't seem like i == currentFrame will do much. Maybe i <= currentFrame ?

1 reply

TimoishaaAuthor
Inspiring
January 1, 2023

oh well, I writed i = currentFrame instead of i == currentFrame. No wonder it wasn't working 🙂

Dan Ebberts
Community Expert
Dan EbbertsCommunity ExpertCorrect answer
Community Expert
January 1, 2023

It doesn't seem like i == currentFrame will do much. Maybe i <= currentFrame ?

TimoishaaAuthor
Inspiring
January 1, 2023

ah yes, because when currentFrame is gonna be higher than i, then i won't increment. Thanks Dan!