Hi, looking for a script that will:
Move a layer to a new random position in a random amount of time and pause in this position for a random amount of time. Then move to the next random position and so on... All the max/min random values should be set in separate variables.
Could the script below be modified to do this? or any other scripts that might work would be hugely appreciated as Im doing a crazy long booring presentation over the next couple of days and need something that will spice it up a bit.. please help!!
RANDOM MOVEMENT
http://www.motionscript.com/mastering-e ... dom-1.html
segMin = .3; //minimum segment duration
segMax = .7; //maximum segment duration
minVal = [0.1*thisComp.width, 0.1*thisComp.height];
maxVal = [0.9*thisComp.width, 0.9*thisComp.height];
end = 0;
j = 0;
while ( time >= end){
j += 1;
seedRandom(j,true);
start = end;
end += random(segMin,segMax);
}
endVal = random(minVal,maxVal);
seedRandom(j-1,true);
dummy=random(); //this is a throw-away value
startVal = random(minVal,maxVal);
ease(time,start,end,startVal,endVal)
Random move & pause URGENT
-
- Posts: 320
- Joined: June 26th, 2004, 10:01 am
- Location: Folsom, CA
- Contact:
I think this expression does what you want.
Dan
Code: Select all
moveMin = .3; //minimum move time
moveMax = .7; //maximum move time
pauseMin = .1; // minimum pause time
pauseMax = 5.; // maximum pause time
minVal = [0.1*thisComp.width, 0.1*thisComp.height];
maxVal = [0.9*thisComp.width, 0.9*thisComp.height];
endT = 0;
j = 0;
k = 0;
while ( time >= endT){
j += 1;
seedRandom(j,true);
startT = endT;
if (j%2){
endT += random(moveMin,moveMax);
k++;
}else{
endT += random(pauseMin,pauseMax);
}
}
if (j%2){
seedRandom(k,true);
endVal = random(minVal,maxVal);
seedRandom(k-1,true);
startVal = random(minVal,maxVal);
ease(time,startT,endT,startVal,endVal)
}else{
seedRandom(k,true);
random(minVal,maxVal)
}
...how is it possible for one person to do so much good? THANKS MATE!!
the presentation I'm doing for this advertising awards has a 60 minute voice over along with some dead boring still charts on the most effective advertising...I told them there are probably going to have to pay for therapy after putting people through this, but they refuse to listen to common sense...at least I can now impress the audience with some serious random action
They will still need professional help though.
the presentation I'm doing for this advertising awards has a 60 minute voice over along with some dead boring still charts on the most effective advertising...I told them there are probably going to have to pay for therapy after putting people through this, but they refuse to listen to common sense...at least I can now impress the audience with some serious random action
![Very Happy :D](./images/smilies/icon_biggrin.gif)
-
- Posts: 320
- Joined: June 26th, 2004, 10:01 am
- Location: Folsom, CA
- Contact:
Sorry to hear about the potential mental health issues of your audience!
Here's a version that's a little better. I put in a random pre-run so that if you use this on multiple layers, they aren't all synchronized at the start.
Dan
Here's a version that's a little better. I put in a random pre-run so that if you use this on multiple layers, they aren't all synchronized at the start.
Code: Select all
moveMin = .3; //minimum move time
moveMax = .7; //maximum move time
pauseMin = .1; // minimum pause time
pauseMax = .5; // maximum pause time
minVal = [0.1*thisComp.width, 0.1*thisComp.height];
maxVal = [0.9*thisComp.width, 0.9*thisComp.height];
seedRandom(index,true); // set pre-run for endT
endT = - random(moveMax);
j = 0;
k = 0;
while ( time >= endT){
j += 1;
seedRandom(j,true);
startT = endT;
if (j%2){
endT += random(moveMin,moveMax);
k++;
}else{
endT += random(pauseMin,pauseMax);
}
}
if (j%2){
seedRandom(k,true);
endVal = random(minVal,maxVal);
seedRandom(k-1,true);
startVal = random(minVal,maxVal);
ease(time,startT,endT,startVal,endVal)
}else{
seedRandom(k,true);
random(minVal,maxVal)
}
Dan
-
- Posts: 1
- Joined: October 27th, 2017, 4:44 am
Is there a way to add the position of the actual layer to this, so you can reposition the layers by hand?
Hi, I cooked up something from Dan Ebberts expression to answer your request. The thing is, you will have to create a script to apply the expression. Just copy/paste this code in notepad and save it as a jsx file, then run it from after effect.
The thing I have to warn you about is that, Dan Ebberts did his expression in order to always keep your layer inside the frame. If you take the actual position of your layer in account, this random mouvement will sometimes put your layer out of the frame as it moves around the actual position of your layer. I did not figure out how to keep it inside the frame AND use the actual position of the layer.
The bright side of it is that if this really bother you, you just have to animate the position from the original to the [0,0] of your comp during the first movement, from there it will always be inside the frame.
Hope to have helped you.
Code: Select all
var PosProp = app.project.activeItem.selectedProperties[0];
if(app.project.activeItem.selectedProperties.length > 1 )
{
alert("You should only have one property selected.")
}
else if(app.project.activeItem.selectedProperties.length < 1 )
{
alert("You should have one Position property selected.")
}
else
{
if( PosProp.name != app.project.activeItem.selectedLayers[0].property(6).property(2).name)
{
alert("This script only works with Position property.\r\nPlease select the position property of a layer.")
}
else
{
applyRandomMotionExp();
}
}
function applyRandomMotionExp()
{
app.beginUndoGroup("ApplyRandomMotionExpression");
var originalPosProp = PosProp.value
if ( PosProp.expressionEnabled != true)
{
PosProp.expressionEnabled = true;
}
PosProp.expression = "moveMin = .3; //minimum move time" +
"\r\nmoveMax = .7; //maximum move time" +
"\r\n" +
"\r\npauseMin = .1; // minimum pause time" +
"\r\npauseMax = .5; // maximum pause time" +
"\r\n" +
"\r\nminVal = 0.1 * [thisComp.width , thisComp.height] ;" +
"\r\nmaxVal = 0.9 * [thisComp.width , thisComp.height] ;" +
"\r\n" +
"\r\nseedRandom(index,true); // set pre-run for endT" +
"\r\nendT = - random(moveMax);" +
"\r\n" +
"\r\nj = 0;" +
"\r\nk = 0;" +
"\r\n" +
"\r\nwhile ( time >= endT)" +
"\r\n {" +
"\r\n j += 1;" +
"\r\n seedRandom(j,true);" +
"\r\n startT = endT;" +
"\r\n if (j%2)" +
"\r\n {" +
"\r\n endT += random(moveMin,moveMax);" +
"\r\n k++;" +
"\r\n }" +
"\r\n else" +
"\r\n {" +
"\r\n endT += random(pauseMin,pauseMax);" +
"\r\n }" +
"\r\n }" +
"\r\n" +
"\r\nif (j%2)" +
"\r\n {" +
"\r\n seedRandom(k,true);" +
"\r\n endVal = random(minVal,maxVal);" +
"\r\n seedRandom(k-1,true);" +
"\r\n startVal = random(minVal,maxVal);" +
"\r\n Mouvement = ease(time,startT,endT,startVal,endVal)" +
"\r\n }" +
"\r\n else" +
"\r\n {" +
"\r\n seedRandom(k,true);" +
"\r\n Mouvement = random(minVal,maxVal)" +
"\r\n }" +
"\r\n" +
"\r\nMouvement";
PosProp.setValueAtTime ( app.project.activeItem.time , originalPosProp - PosProp.value );
PosProp.expression = PosProp.expression + "+ value;"
app.endUndoGroup();
}
The bright side of it is that if this really bother you, you just have to animate the position from the original to the [0,0] of your comp during the first movement, from there it will always be inside the frame.
Hope to have helped you.