Colin Braley
Forum Replies Created
-
[Filip Vandueren] “Nice expression, Colin,”
Thanks Filip
[johnnyfix] “Is there a way to restrict the movement of the layers to just the X and Y axis?”
Sure, I think this expression below should do it, but I don’t have AE at the computer I’m at, so I cant test it to be sure. Apply this expression to the position property of every layer you want to be affected:
//begin expression
maxDisplacement = 500;
maxDistance = 700;
//–
cameraPos = thisComp.activeCamera.position;
thisPos = position;
vec = cameraPos – thisPos;
distance = length( vec );
dispAmt = ease(distance , 0 , maxDistance, maxDisplacement , 0);
normalizedVec = normalize( [vec[0] , vec[1]] );
position – (normalizedVec * dispAmt)
//end expressionIf this dosen’t work, let me know.
~Colin -
This is definetly possible, and is a very neat idea, I never thought of doing somehting like this. Assuming there is no parenting goign on, this expression should work for you:
//begin expression
maxDisplacement = 500;
maxDistance = 700;
//--
cameraPos = thisComp.activeCamera.position;
thisPos = position;
vec = cameraPos - thisPos;
distance = length( vec );
dispAmt = ease(distance , 0 , maxDistance, maxDisplacement , 0);
normalizedVec = normalize( vec );
position - (normalizedVec * dispAmt)
//end expressionWhat this does is as the camera moves closer to a layer, the layer moves away, in the direction from the camera to the center of the layer. If you want the layers to move away farther, adjust maxDisplacement, and if you want the layers to begin repelling at a closer distance to the camera, make maxDistance smaller. Enjoy.
~Colin
-
[Lord Scales] “I understood almost nothing there =(.
Could you explain what “++” does? And “”? And the “return”?”Lord Scales, heres a quick explanation:
the following section of code:
function addLeadingZeroes( v ){
for( i = 0; i < Math.abs( amtOfDigits - (v + "").length ); i++) v = "0" + v; return v; } is just creating a custom function to add leading zeroes to a number. Functions like this aren't really necessary, they are just a handy way to keep you from writing the same code multiple times throughout an expression. Once you have "declared" this function, you can use it just like any other function built into AE like random(), Math.round(), etc. This function takes in 1 "argument," which will be referred to as "v" within the function itself. It takes this number v, converts it into a String (a series of letters) and then adds some zeroes to the front of it. The code: for( i = 0; i < Math.abs( amtOfDigits - (v + "").length ); i++) v = "0" + v; is something called a "for loop." It is just a looping structure, similar to other loops you may have head of like a "while loop." You could use a while loop in this situation, I just like using for loops because they are more concise. All this loop is doing is adding zeros to the front of "v" until the number of digits in the number is equal to the variable amtOfDigits. If you want a more detailed description of how this loop is actually working, let me know, but I reccommend you learn about basic for loops and while loops in javascript first. And by the way, the line with "return v" is just saying "the result form this function to be given back is v." ~Colin -
Alright, heres a more step by step description of what to do:
-Import your song into AE
-Drag your song onto the “Create new comp” button at the bottom of the project window, and you will have a comp that is the same duration as your song
-Create a new text layer by going to Layer>New>Text.
-Select this new text layer, and twirl down the little trianges until you see a property called “Source Text”
-Select the “Source Text” property and goto Animation > Add Expression, or just alt+click on the stopwatch.
-In the little text are that is created for your expression copy and paste in the following code:
amtOfDigits = 2;
seconds = Math.round( time % 60 );
minutes = Math.floor( time / 60 );
function addLeadingZeroes( v ){
for( i = 0; i < Math.abs( amtOfDigits - (v + "").length ); i++) v = "0" + v; return v; } addLeadingZeroes(minutes) + ":" + addLeadingZeroes(seconds)~Colin
-
Paste this expression into the sourceText property of a text layer and you will have a nice minutes and seconds counter:
//begin expression
amtOfDigits = 2;
seconds = Math.round( time % 60 );
minutes = Math.floor( time / 60 );
function addLeadingZeroes( v ){
for( i = 0; i < Math.abs( amtOfDigits - (v + "").length ); i++) v = "0" + v; return v; } addLeadingZeroes(minutes) + ":" + addLeadingZeroes(seconds) //end expression~Colin
-
Would you like this random value to be a new value each frame? If so, try this:
Math.round( random() ) * 100
If you would like the value to be the same for the duration of the comp, try this:
seedRandom( index , true );
Math.round( random() ) * 100
~Colin
-
From what I understand, if the torso is moving to the right, you want the legs layer movie to play regularly and, to play in reverse if the legs layer is moving to the left? If this is the case, enable time remapping on the legs and apply the following expression to the time remap property:
//begin expression
torsoLayer = thisComp.layer("TORSO");
dampen = 1200;
//--
dur = this.source.duration;
finalTime = 0;
for( i = 0; i < time; i+= thisComp.frameDuration ){ xVeloc = torsoLayer.position.velocityAtTime( i )[0]; finalTime += xVeloc/dampen; } if( finalTime < 0 ) (dur + finalTime) % dur else finalTime % dur //end expressionThis worked fine when I tested it out, but it will look best if the movie of your "legs" layer is looping. Also, since I don't know how fast your torso layer will be moving, you will need to adjust the "dampen" variable until it looks good. If the legs are moving too fast, try increasing the value of dampen. You will also need to pickwhip the "torsoLayer" variable properly.
~Colin -
Ive got some expressions for you that work okay, but not great. If I have some time tomorrow or the next day, I might tweak them to make it look better. These are a bit complicated and have alot of references to pick-whipped properties in the expressions, so if you want me to post the .aep file (After Effects 7) I can do that. Well anyway, here you go:
try this one for position:
//begin expression
wind = thisComp.layer(“Controls”).effect(“wind”)(“Slider”);
//you can keyframe the wind parameter, negative values
//will make the petals blow in the opposite direction
minMass = thisComp.layer(“Controls”).effect(“min_petal_mass”)(“Slider”);
//don’t keyframe this, it is theminimum mass for each petal
maxMass = thisComp.layer(“Controls”).effect(“max_petal_mass”)(“Slider”);
//this is the maximum mass for each petal, dont keyframe me
gravity = thisComp.layer(“Controls”).effect(“gravity”)(“Slider”);
//this is the strength of the gravitational force on the petals
//dont keyframe this
minBlowAway = thisComp.layer(“Controls”).effect(“min_blow_away_time”)(“Slider”);
//this value is the earliest time a petal can blow away
//dont keyframe this
maxBlowAway = thisComp.layer(“Controls”).effect(“max_blow_away_time”)(“Slider”);
//this value is the latest time a petal can blow away
//dont keyframe this
//———//——————————————–
seedRandom( index, true );
mass = random( minMass, maxMass );
blowAwayTime = random( minBlowAway, maxBlowAway);
if( time < blowAwayTime){ value }else{ adjustedTime = time - blowAwayTime; accelY = gravity/mass; posX = position[0] + wind * adjustedTime; posY = position[1] + accelY * Math.pow(adjustedTime,2); [posX, posY] } //end expression then, try this one for rotation //begin expression //if you are going to add more petals, decrase the value of the variable gap //use the following formula for determining what gap should be // gap = 360/ numberOfPetals gap = 10; rotationTendency = 1; //make this higher, petals will spin faster wind = thisComp.layer("Controls").effect("wind")("Slider"); //---------------------- startRot = index * gap; totalRot = startRot; for(i = 0; i < framesToTime( time); i++) { totalRot += wind/rotationTendency; } totalRot //end expression Both of these expressions have some explanation of what each variable does. For these to work right, you will need a layer named "Controls" with a few sliders on it. These should be called wind, min_petal_mass, max_petal_mass, gravity, min_blow_away_time, max_blow_away_time and should have the values of about 3.75, 20, 25, 45, 2, and 5, respecttively. I wis I had more time to explain, but I have to go. ~Colim -
Yes, you could consider After Effects CS 3 the same thing as After Effects 8. While it does have new features that are not in version 7.0, whether or not you need to upgrade depends on if you need these features to do your work.
~Colin -
create a text layer, and apply this expression to the source text property:
//Begin expression
countBeginTime = 0;//seconds
countEndTime = 15;//seconds
beginCount = 0;
endCount = 500000000;
//–
linear( time, countBeginTime, countEndTime, beginCount, endCount)
//End expression~Colin Braley