Quantcast
Channel: Adobe Community : Popular Discussions - After Effects Expressions
Viewing all 47983 articles
Browse latest View live

DUIK Bassel Walk Cycle Mover

$
0
0

Hi there!

 

For everybody who uses DUIK Bassel walk cycle and don't want to move the character comp by hand as the character walks, here is the expression:

 

iniX = value[0];
myframe = timeToFrames(time);
skal = transform.scale[0]/100;
mycomp = thisLayer.source.name;
myTime = sourceTime(time);

for (n = 0; n <= myframe; n++){    timeback = thisComp.frameDuration * n;    step = comp(mycomp).layer("C | Walk Cycle").effect("Walk Cycle")("Step amplitude (cm)").valueAtTime(myTime - timeback);    stepperframe = step / (comp(mycomp).layer("C | Walk Cycle").effect("Walk Cycle")("Cycle duration (f)") / 2);    iniX += stepperframe;    
}

myX = iniX * skal;
[myX ,value[1]];

 

 

Apply it to the position of the character comp. The final structur should look like this:

 

character comp -> Position -> this Expression

     |

     |_ character layers, DUIK rig, controllers, walk cycle controller

 

The code is easy and straight forward, but works with keyframed "general motion" in the walk cycle controller, time shifted character comp, scaling in every dimension and every direction of walking.

 

Feel free to use, spread, edit.

 

Cheers,

Martin


counting numbers expression with commas

$
0
0

I am using the following expression to create a number countdown but I need it to recognize or insert commas in eight digit numbers. Can anyone tell me how to alter it:

 

 

startT = 0;

endT = .5;

beginVal = 12400000;

endVal = 10700000;

t = linear(time,startT,endT,beginVal,endVal);

Math.floor(t) + ''

 

 

P.S. there are also times that I'd like to add dollar signs or percent signs.

How to delay an animation

$
0
0

Sorry for my bad english: i'll try to be clear.

Once a layer has some animation (position, scale etc),

how can i link another layer to this first one (or the animated property of the first one to the another equivalent one)

and make the second layer animation delay some number of frames?

 

Another situation:

same start point above, but, after duplicate that layer,

how to delay the animation time some frames?

 

Thanks for the attention

How to get the footage's current frame number in expression?

$
0
0

There are 2 layers.One is text layer,one is sequence layer.

Footage has begun from the 20th frame.

Therefore, the number of composition's current frame number and footage's frame number has shifted.

 

I want to show footage's frame number in text layer . not composition's frame number.

How to get the footage's current frame number in expression?

 

 

Tatsuya

Math.round for Shape layers to land on whole pixels?

$
0
0

Trying to keep my shape layers on whole pixels to avoid subpixel blurring.

 

For one-dimensional properties, this works fine:

 

Math.round(value);

 

But for two dimensional props, I'm running into errors with things like this:

 

temp = Math.round(content("Rectangle 1").content("Rectangle Path 1").size.value)

(temp[0],temp[1])

 

temp = Math.round(content("Rectangle 1").content("Rectangle Path 1").size)

(temp[0],temp[1])


 

I'm sure my syntax is off. Properties in arrays always give me problems. Can you help?

Numbers expression - add letter "B" for billions

$
0
0

I have a question for Dan Ebberts.   Dan, the expression you have for a text layer for  numbers (see below)  I wanted to see if it's possible to add a letter at the end of the expression such as the letter B to represent Billions so that the final number count would be $1.7B.  I appreciate any help you can provide

 

Best Regards

 

Ira

 

numDecimals = 1;

commas = true;

dollarSign = true;

beginCount = 0;

endCount = 1.7;

dur = .5;

 

t = time - inPoint;

s = linear (t, 0, dur, beginCount, endCount).toFixed(numDecimals);

 

prefix = "";

if (s[0] == "-"){

  prefix = "-";

  s = s.substr(1);

}

if(dollarSign) prefix += "$";

 

if (commas){

  decimals = "";

  if (numDecimals > 0){

    decimals = s.substr(-(numDecimals + 0));

    s = s.substr(0,s.length - (numDecimals + 0));

  }

  outStr = s.substr(-s.length, (s.length-1)%3 +1);

  for (i = Math.floor((s.length-1)/3); i > 0; i--){

    outStr += "," + s.substr(-i*3,3);

  }

  prefix + outStr + decimals;

}else{

  prefix + s;

}

how to parent a layer on a negative x,y position value ?

$
0
0

Hey there i have a composition with 2 text layers on it one is scaled -100 on the y  axis to get a reflection effect

and i added a wiggle expression to the the upper layer and i want the reflection layer to have the same moment as the upper layer  but on a negative x,y direction.

Using valueAtTime syntax problem?

$
0
0

Hi guys

 

I want to follow position of current layer "cardio.ai" but with a delay.

 

This code currently works:

 

tempX = transform.position[0];

tempY = thisComp.layer("cardio.ai").transform.position[1];

[tempX, tempY]

 

But if I do this:

tempX = transform.position[0];

tempY = thisComp.layer("cardio.ai").transform.position[1].valueAtTime(time -1);

[tempX, tempY]

 

it will not work.

 

I may be having problems with the API or syntax but I am just learning this and can't figure out what's going on.

 

Thanks


Add a delay to an expression

$
0
0

So I have an expression that controls the opacity something along the lines of

 

if(other layer >50) opacity(100) else opacity(0)

 

is there a way I could stick a delay in the else part of my expression. Logically I want the opacity to go to 0 but i want it to wait a second before it does. Would it be something like

 

else opacity(0) delay(.1)

 

i don't want to delay the whole expression just the part that makes the opacity go to 0

 

any help would be great

Is it possible to call a script file from an expression?

$
0
0

Hello everyone,

 

tl;dr Accessing path vertices via expression doesn't seem possible, but scripts can, so is it possible to do it by calling a script file inside the expression?

 

My goal is to access the number of vertices in various path objects and use this value in an expression. The expression is driving a trim path's offset property and the expression use relative naming so that I can copy the trim path to 500 other shape layers groups and have a different effect (speed of the offset) for each group depending on the number of vertices of each path.

 

I've been looking for a solution to this problem for quite some time now and my conclusion is that you simply cannot access path vertices via expression, whether the path is in a mask or a shape layer.

Is this correct?

 

With a mask on a solid layer and according to the After Effects Scripting Guide I should be able to do:

thisComp.layer("Black Solid 1").mask("Mask 1").maskPath.value

or

thisComp.layer("Black Solid 1").mask("Mask 1").maskPath.value.vertices

or

thisComp.layer("Black Solid 1").mask("Mask 1").maskPath.value.vertices.length

I also tried:

thisComp.layer("Black Solid 1").mask("Mask 1").maskPath.vertices.length

and so on...

 

But when debugging this with the source text of a text layer I only get "undefined" for the value and errors for the other expressions ("property named 'vertices' in Class 'Property' is missing or does not exist").

I'm pretty sure these are the correct methods since a lot of scripts are using those, including:

http://omino.com/pixelblog/2008/12/25/ae-mask-vertices-from-extendscript/

http://www.crgreen.com/aescripts/actual_scripts/Connect_Point_to_Mask_Vertex.jsx

http://aescripts.com/maskvertexexpression/

 

So if directly accessing the path arrays via expression is not possible, I was thinking about calling, in each expression, an external script which would then return the number of vertices there is in each arrays. It would look like something like this (pseudo-code):

arrayLength = content(thisProperty.propertyGroup(2).name).content("Path 1").value.vertices.length

return arrayLength

And then use the value I get from the script to adjust the speeds in my expressions:

time*arrayLength*thisComp.layer("Controller").effect("Speed")("Slider")

 

So is it possible to call a script file inside an expression? How?

If not, do you have any other suggestion?

 

Thanks.

 

Reference: After Effects CS6 Scripting Guide, page 172.

I have to fix some expressions in After Effects.

$
0
0

스크린샷 2016-01-11 오후 1.23.34.png

When I turn on some file at first, it suddenly appear that comment, which said 'In this project, it has expression error 1/1 error'

 

Actually, I'm a learner of After Effect so I do not know fluently what's what.

 

Here is the expression having error.

 

 

transComplete = effect("Slide Master Control")("Transition Completion");

if (effect("Slide Master Control")("reverse direction") == true)

    {xPos = linear(transComplete, 0, 100, thisLayer.width, 0)}

else

    {xPos = linear(transComplete, 0, 100, -thisLayer.width, 0)};

[xPos, 0]



Thank you.

 

If you want to email me, please send me into 'triumphalboy@gmail.com'.

 

I can send you this aep file for you in order to fix the problem.

haw use 2 code loop and code motion2 ?

$
0
0

hello
help me

haw use 2 code loop and code motion2

example

motion 2 script

try {

 

  amp = effect("Rotation - Overshoot")("ADBE Slider Control-0001") / 2.5, freq = effect("Rotation - Bounce")("ADBE Slider Control-0001") / 20, decay = effect("Rotation - Friction")("ADBE Slider Control-0001") / 20, n = 0, 0 < numKeys && (n = nearestKey(time)

            .index, key(n)

            .time > time && n--), t = 0 === n ? 0 : time - key(n)

        .time, 0 < n ? (v = velocityAtTime(key(n)

            .time - thisComp.frameDuration / 10), value + v / 100 * amp * Math.sin(freq * t * 2 * Math.PI) / Math.exp(decay * t)) : value;

 

 

} catch (e$$4) {

    value = value;

}

 

and use loop code

loopOut(type = "cycle", numKeyframes = 0)

After Effects Combine x2 Expressions - Bounce & loopOut

$
0
0

I'm after help combining x2 expressions. A bounce expression like below...

 

n = 0;

if (numKeys > 0){

n = nearestKey(time).index;

loopOut("cycle");

if (key(n).time > time){

n--;

}

}

if (n == 0){

t = 0;

}else{

t = time - key(n).time;

}

if (n > 0){

v = velocityAtTime(key(n).time - thisComp.frameDuration/10);

amp = .05;

freq = 4.0;

decay = 2.0;

value + v*amp*Math.sin(freq*t*2*Math.PI)/Math.exp(decay*t);

}else{

value;

}

 

...with the standard loopOut("cycle") expression. I have a few key frames to lift an object slowly then to drop it quickly (hopefully with a bounce) and I need to repeat this indefinitely. Can any one help?

Controlling tangents of a shape layer (cc 2018)

$
0
0

Figured it would be a lot of discussion re: the new scripting functionality of paths, but I can't find anything on this topic.

 

Is it possible to control the in and out tangents of an existing object by reference say the width of a shape layer? In other words: can I control the shape layer objects tangents other than just using the values on other objects.

 

I'm trying to define the tangent value this way:

myPath = thisComp.layer("Shape Layer 1").content("Shape 1").content("Path 1").path

myPath.inTangents()[2] = [120,50]

(the values are not referencing anything, I know!)

I get the 'object of type array found where a Property is needed' warning.

 

What is the correct way of doing this? Can't find any example in the expression reference help.

Custom easing function start time

$
0
0

Hey everyone, I'm attempting to write an expression to animate values using a custom easing amount, to use as a replacement of the inbuilt "ease(t, tMin, tMax, value1, value2)".

I have everything working, except can't seem to work out how to get the animation to start at a specified time (it currently always starts at 0 rather than startTime.

 

Here's my expression as it is currently:

 

var startVal = value; // Start value
var endVal = value + 500; // End value
var duration = 1; // Duration in seconds
var easing = 5; // Easing amount, 1 is linear
var startTime = 2; // Starting time

easeValues(duration, startVal, endVal, easing, startTime)

function easeValues(dur, startV, endV, ease, startT) {

  normalizedEasing =(Math.ceil(ease/2) * 2)-1;  var easedTime = easeTime(startT + time, startT, startT + dur, dur);  return linear(easedTime, startT, startT + dur, startV, endV);
}

function easeTime(t, b, c, d) {
  if ((t/=d/2) < 1) {    return c/2*Math.pow(t, normalizedEasing) + b;  } else {    return c/2*((t-=2)*Math.pow(t,  normalizedEasing -1) + 2) + b;  }
}

Anyone able to shed some light on why it might always be starting at 0?

 

Thanks,

Tim.


Slider Control expression position

$
0
0

Hello everybody,

 

Hopefully somebody can help me out with this:
There are two text layers in my composition and I have a rectangle that is linked to the size of the text of these layers. This worked quite wel so far, but

if my first text layer has more than one line of text, I need to reposition my second text layer. Therefore I made a slider which controls the vertical position of my second text layer. Now I would like to link the size of the rectangle to the y-position of the second text layer. So that if I lower the second text layer, the rectangle grows with a certain amount. Hopefully I could explain the problem clear enough.

This is my code. Please tell me what I am doing wrong. Thank you so much in advance.

 

 

heightTextLayer1 = thisComp.layer("Text Layer 1").sourceRectAtTime().height+300;

 

positionTextLayer2 = thisComp.layer("SLIDER CONTROL Positie").effect("Slider Position Text Layer 2")("Slider").value;

 

if (positionTextLayer2 >= 0) {

heightTextLayer2 =  thisComp.layer("Text Layer 2").sourceRectAtTime().height+300;}

 

 

else if (positionTextLayer2 >= 800) {

heightTextLayer2 =  thisComp.layer("Text Layer 2").sourceRectAtTime().height+700;}

 

 

else if (positionTextLayer2 >= 900) {

heightTextLayer2 = thisComp.layer("Text Layer 2").sourceRectAtTime().height+800;}

 

 

else {positionTextLayer2 = thisComp.layer("Text Layer 2").sourceRectAtTime().height+1000;}

 

x = 1920

if (heightTextLayer1 > heightTextLayer2) {y = heightTextLayer1} else {y = heightTextLayer2} 

[x, y]

Keeping linked 3D null orientation straight

$
0
0

When using Cinema 4D, I routinely attach AE layers to exported 3D nulls.  And everything works as expected.

 

However, I have a project where camera and object are at angles and I need the AE layer to keep its orientation always pointing up, but still rotating around as normal.

 

(click to watch animation)

cube-rotate.gif

 

 

 

For this example below, the layer was linked normally to XYZ rotation and XYZ position of the null. But I manually keyframed the orientation  (which I know is usually a no-no). Any expressions that  would keep a layer level no matter the 3D rotation or 3D position? "Orient to Camera" doesn't work. I don't need the layer to always face the camera because it needs to rotate with the null

 

(click to watch animation)

cube-orient-up.gif

Rotating Object to Music Expression?

$
0
0

Hello all,

 

I've been deep into a project for a long time and it's coming to the end.  I have Sound Keys set up with ONE output. 

 

I am looking to rotate a circle only to the Sound Keys Output, although I do not want the circle to move right 10 degrees then move back (-10 degrees), rather I'd like it to continuously move clockwise as the output value continuously adds itself to the previous value based off time.  

 

Is there an expression that would cover that?  Here's an example of what I thought was 'close' but the circle keeps going back and forth rather than continously around in 360 degrees. 

 

time+comp("Main Comp").layer("Sound Keys").effect("Sound Keys")("Output 1")

 

I've attached a screen shot as well for guidance. 

 

Thank you for your help!

RyanScreenshot_4.png

Extract only true degrees from rotation

$
0
0

Hi Guys,

 

I need to find a way to extract true degrees from the rotation transform. So instead of reading 1x-90 or 2x270, It just needs to read the 270 degrees part.

 

So if somethings continuously rotates, if you go beyond 360, it goes to 1x1 on the display or 361 if you read it out in expressions. But I only need to now if something is beyond 180 degrees or not, everytime it rotates.

 

So if it says 1x179, then it needs to understand that it is 179 and therefore not greater then 180 or not beyond the half of the circle, but it reads this of course at (1x360+179) 539, which IS greater then 180. So my if-then doesn't detect when its in the second half of the circle past one rotation.

 

Is there anyone who has discovered a function or some sort that does that?

 

Kind regards,

Marten.

Text Source Link (FONT?)

$
0
0

Good day!

 

Starting to make a client friendly project, I wanted it to make it easy for him to change text with a control comp.

When trying to change the source text the actual texts changes, that's good! But when changing the source text font the actual text layer changes the text but not the font. Any way there is a solution to this problem so I can make easier templates for clients? This can be by scrips or any other way. I really want to fix this problem.

 

Thanks in advance.

David

 

See printscreen. jpeg example.png

Viewing all 47983 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>