Skip to main content
johnmcmullin
Inspiring
September 26, 2023
Question

vary expression-driven spinning

  • September 26, 2023
  • 1 reply
  • 203 views

I've written an expression (partly using code I've found elsewhere) to animate a group of 5 spheres so that they can either circle around a null or follow it with a delay between them. Generally it works well but when I try to animate the circling speed it doesn't animate smoothly. Between two keyframes, it sometimes appears to reverse, slow down, or speed up wildly when it should be gradually gaining speed. I think this is because the trigonetry doesn't increase linearly and so one frame doesn't progress as expected.

 

My code is as follows:

 

ballnum=5;
nullpos=thisComp.layer("Null 1").transform.position;

radius = thisComp.layer("expression sliders").effect("radius")("Slider");

startAngle = degreesToRadians(ballnum*72); // yourStartAngle in degrees

T = thisComp.layer("expression sliders").effect("Rotation speed")("Slider"); // speed in rotations per second;

angularSpeed = 2 * Math.PI*T;


xt = nullpos[0] + radius * Math.cos(time*angularSpeed + startAngle);
yt = nullpos[1] + radius * Math.sin(time*angularSpeed + startAngle);

pos1=[xt, yt];


follow=thisComp.layer("expression sliders").effect("circle to follow position")("Slider");
delay=thisComp.layer("expression sliders").effect("delay amount")("Slider")/25;
delayA=(ballnum-1)*delay
pos2=nullpos.valueAtTime(time-delayA);

ease(follow,0,100,pos1,pos2)

 

The last part of the expression allows me to ease between the balls rotating around the null and following it with a delay.

 

Would be very grateful for any help on this one.

 

John

This topic has been closed for replies.

1 reply

Dan Ebberts
Community Expert
Community Expert
September 26, 2023

Speed control is tricky. This might help:

https://www.motionscript.com/articles/speed-control.html

 

johnmcmullin
Inspiring
September 26, 2023

Thanks Dan. That makes sense. Reminds me how complicated all this maths is.

In the meantime, I seem to have done it a different way, by moving the anchor point with a slider and rotating each ball around the position of the null. Seems to be simpler, although it messes up the way the scale works.