Skip to main content
Participant
April 14, 2023
Question

After Effects expressions - pendulum motion not working properly

  • April 14, 2023
  • 1 reply
  • 1372 views

Hello, 

 

I am trying to make a triangle shape in After Effects swing in a pendulum motion which decays.  This is the expression I have used:

 

timeToStart = 8;

if (time > timeToStart)

{ Math.sin((time-timeToStart)*10)*50/Math.exp(time-timeToStart)

; } else {

; value

}

 

The problem that I am having is that after the 8 second mark, the triangle returns to the original position it was in, before I put the code in. To explain better, at the beginning of the animation the triangle does a circular rotation and then stops in a specific almost horizontal position. And what I want it to do after it does that circular motion, at the 8 second mark, is swing down from it's horizontal position to a top down position (meaning that the long pointed end of the triangle is pointing up). The anchor point is in the long point of the triangle which is pointing up. I hope that makes sense - I want it to swing down from it's anchor point in a pendulum motion which decays until it is still in a completely vertical position. 

 

However what is happening is that the expression I have used overrides the rotation and causes the triangle to jerk up into its original almost horizontal position, and then it does the pendulum-decay-animation. The animation is perfect, but the position is wrong. 

 

Any idea on how to fix this? Hopefully this wasn't too confusing to understand 😕😕

This topic has been closed for replies.

1 reply

Dan Ebberts
Community Expert
Community Expert
April 14, 2023

Try changing the third line to:

{ value + Math.sin((time-timeToStart)*10)*50/Math.exp(time-timeToStart)
Participant
April 15, 2023

Thanks for your answer! But the problem still persists. now the code is like this:

 

timeToStart = 8; 

if (time > timeToStart) 

{ value + Math.sin((time-timeToStart)*10)*50/Math.exp(time-timeToStart)} else { 

; value

}

 

the triangle still returns to it's original wrong position when it does the animation.
Any idea why it does that?

Dan Ebberts
Community Expert
Community Expert
April 15, 2023

It's hard to picture exactly how you have things set up, but see if this gets you closer:

timeToStart = 8; 
val = value;
if (time > timeToStart) 
  val = value*Math.cos((time-timeToStart)*10)/Math.exp(time-timeToStart);
val