## Increment Rotation At Markers

Moderators: Disciple, zlovatt

lloydalvarez
Enhancement master
Posts: 460
Joined: June 17th, 2004, 9:27 am
Location: New York City, NY
Contact:
This expression will increase (and animate) the rotation by the user defined number or degrees at every marker on the layer. If you set the duration to anything more than 0 the rotation will animate into the marker. In other words it will start the rotation f frames before the marker and it will finish the rotation at the marker.

Code: Select all

``````
f=5; //duration in frames of rotation, set to zero if you want it to click
d=20; //degrees to rotate

f=framesToTime(f, fps = 1.0 / thisComp.frameDuration);
n = 0;
if (marker.numKeys > 0){
n = marker.nearestKey(time).index;
if (time > marker.key(n).time && n < marker.numKeys){
n++;
}
r=(d*(n-1)) + value;
linear (time,marker.key(n).time-f,marker.key(n).time,r,r+d);
}
``````
-Lloyd
lloydalvarez
Enhancement master
Posts: 460
Joined: June 17th, 2004, 9:27 am
Location: New York City, NY
Contact:
This expression will oscillate rotation back and forth at markers:

Code: Select all

``````f=5; //duration in frames of rotation, set to zero if you want it to click
d=20; //degrees to rotate

r=value;
f=framesToTime(f, fps = 1.0 / thisComp.frameDuration);
n = 0;
if (marker.numKeys > 0){
n = marker.nearestKey(time).index;
if (n%2) {d=d*-1; r=r-d;}
linear (time,marker.key(n).time-f,marker.key(n).time,r,r+d);
}
``````
Disciple
Posts: 137
Joined: June 5th, 2004, 8:05 am
Location: Los Angeles, CA
Contact:
Hey Lloyd

This might come in handy for me on a current project. How would you combine this with a wiggle? ie if I wanted the wiggle to increase based on your script?

Thanks
Alex
lloydalvarez
Enhancement master
Posts: 460
Joined: June 17th, 2004, 9:27 am
Location: New York City, NY
Contact:
you want the amount of wiggle to increase at each marker?
Disciple
Posts: 137
Joined: June 5th, 2004, 8:05 am
Location: Los Angeles, CA
Contact:
Yes, sorry if I wasn't clear. I'm basically trying to find ways to control the evolution of a wiggle parametrically, ie without keyframes from a slider. Markers are one good way I hadn't thought of...

Thanks!
Alex
lloydalvarez
Enhancement master
Posts: 460
Joined: June 17th, 2004, 9:27 am
Location: New York City, NY
Contact:

Code: Select all

``````freq=24; //wiggle frequency in frames per second
s=0; //wiggle start amount
d=20; //amount to increase wiggle at each marker
f=15;  //duration in frames of transition to next amount, set to zero if you want it to click

f=framesToTime(f, fps = 1.0 / thisComp.frameDuration);
n = value;
if (marker.numKeys > 0){
Â  n = marker.nearestKey(time).index;
Â  if (time > marker.key(n).time && n < marker.numKeys){
Â  Â n++;
Â  }
r=(d*(n-1))+s;
a=linear (time,marker.key(n).time-f,marker.key(n).time,r,r+d);
wiggle(freq,a);

}``````
Atomic
Posts: 157
Joined: April 30th, 2007, 5:55 am
Location: United States, Ohio
Can this be used with audio somehow?

Ideally to rotate on the beat. I often have the raw tracks for music, such as only the kick or only the snare fairly well isolated.
"Up And Atom

No...No

Up And At Them!"
lloydalvarez
Enhancement master
Posts: 460
Joined: June 17th, 2004, 9:27 am
Location: New York City, NY
Contact:
totally, that's what I wrote it for in the first place.. simply place markers on your layer at every beat..

if you want a more automated way to do that, you can reference this tutorial by Dan: http://www.motionscript.com/design-guid ... igger.html

and feed my expression the threshold time instead of the marker time. But in my experience i get better results when I mark the beats myself.. at least use Trapcode's soundkeys which can let you isolate frequencies better.

-lloyd