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

Expression for Trimmed Paths on Dashed Lines

$
0
0

I'm editing a trim paths expression and have run into a little nuanced issue.

The smoke animation below (rendered quickly for demo purposes, so no judging) is going to be a sort of neon light animation (as is the rest of the comp), I just haven't gotten that far into building this. I slowed down the footage a little so you can see my problem, which is that the yellow dashed stroke is not lining up with the gray dashed stroke, though they have the exact same paths and dash settings.

 

The only difference is that the yellow stroke has an expression that tells it where on the path it needs to be. This is applied to the end of the path:

total = 5;
step = 100/total;

cycledur = .75;
t = (time - thisLayer.inPoint); 

if (t < cycledur) {     y = (step/(cycledur - cycledur/total))*(total-1)*t + step;     ynorm = y/step;     ret = step*Math.floor(ynorm);
} 
else {     ret = 0;
}
ret

 

and yes, before you say it: I defined a linear function by hand when I had the linear() method at hand. Oops. I forgot about it for a second.

 

What's actually happening? Inside the if conditional, I am taking the result of the linear function, then dividing it by the step value. Once that is done, I find out if I have reached the next step or not using the floor() function. Then I multiply back to get to the actual step.

(I put in some magic numbers that are actually defined in a null object layer, but that's just so you can see the numbers.)

 

The start property of trim paths simply reads the value returned in the above expression and subtracts the by the step number:

//step defined up here

endv = content("blahblah")...end;
endv - step;

 

The animation loops, and I have a debug text layer in the below animation showing the value of end on the rightmost path.

Notice that it is actually reaching 100% but also that the actual path ends well past the point it reaches. The silver lining is that it is following the path I guess.

 

How do I get one path to line up with the other? I can post pictures of the dashed line settings too, but there is no difference between the two.

 

 

cig_1.gif

 

UPDATE: I think I have begun to solve the issue. The start value of Trim Paths actually defines where the dashed line starts (or so it seems). Since the path does not exist yet, it is possibly just traveling 80% along the path (for example), starting there, then going 20% of the dashed-line distance. Since that 20% is not entirely stroked, I am receiving a little bit of the un-dashed areas, which is why it doesn't *appear* to go the full 100%. Okay. I will search for a solution to my boldfaced question, but I now know how to explain the discrepancy.


Decimal numbers in expression

$
0
0

Hi! I have created a counter on a text layer that counts length in increments om 40 cm controlled by a slider, I added this expression to the source text property and it works great except for the decimals. 

 

t = effect("Slider Control")("Slider")

x = Math.round(t/.4)*.4+0.0001

 

 

x = x + " Meter"

 

 

x.toString().replace(".", ",");

 

 

It now counts 0,001 Meter.... 0,4001 Meter... 0,8001 Meter.... 1,2001 Meter..... but i want it to only show 2 decimals: 0,40..0,80..1,20..1,60...

 

I added the +0.0001 in Math.round to get decimals at the whole numbers. I.e. 4 Meter is now 4,0001 Meter... But how do I remove the last two digits? Or is there another way to always show 2 decimals? I need the counter speed to be controlled over time and masking is a problem since the font I use is not monospaced.

 

Thank you.

Getting global coordinates from parented local coords.

$
0
0

I have a mocha tracked null. I child another null thats slightly offset in XY. Now the child's coordinates are relative to the parent. But how can I get the child's true position in the comp?

 

This seems too easy:

 

thisComp.layer("parentNULL").transform.position + thisComp.layer("childNULL").transform.position

 

Am I missing something?

Storing a position value from the previous frame

$
0
0

Hey guys,

 

So, I'm trying to assign the X value a null object had at the previous frame so I can continue to subtract a number from it cumulatively. I'm trying to assign it to a variable (prevframe). I'm not sure where I'm going wrong, but the line I'm trying to do it on is written as follows:

 

prevframe = transform.xPosition.valueAtTime(time-(1/24))

 

So in my mind, this should be taking a look at the value of X on the null, then looking back in time to figure out what it's value was on the previous frame (my frame rate is 24, so I'm dividing 1 second in to 24 pieces and telling it to subtract that much from the current time), and assigning whatever that returns to the variable. But it's just returning a static value, even though I'm subtracting from it. I feel like it's not the correct syntax, but I really have no idea.

 

I want to continue to subtract a value which is based on the velocity of another object from this, which I have worked out, I just can't figure out how to reference what this nulls X position was in the previous frame so it always returns the same value until all motion has stopped. The formula the variable is being run through looks like:

 

finalposition = prevframe - camvelocity

 

Which is then assigned to the final X position of the null object.

 

So, I'm not sure where I'm going wrong. I hope I've provided enough information to help someone wrap their head around this and hopefully help me solve it.

 

Thanks in advance,

 

-Seth

Random scale with equal values for xScale and yScale

$
0
0

Hi there,

 

professional scripters might not think of this to be a problem, but I cannot solve it on my own after hours of trying.

 

I found a random script on www.motionscript.com (thank you so much Dan, for this great resource, you're awesome!).

 

The sample for "random motion - more chaotic" is exactly what I need, but for the scale property with same random values for xScale and yScale (so that the random scaling is proportionally). I cannot figure out how to do this. I know I need another variable, but I don't know where.

 

Actually, I want to have a matrix of dots, each scaling up and down again randomly and independently in size and timing...

 

This is what I got so far:

 

segMin = .3;
segMax = .7;

minValX = 100;
maxValX = 200;
minValY = minValX;
maxValY = maxValX;

minVal = [minValX, minValY];
maxVal = [maxValX, maxValY];

seedRandom (index, true);
segDur = random (segMin, segMax);
seed = Math.floor (time / segDur);
segStart = seed * segDur;
seedRandom (seed, true);
startVal = random (minVal, maxVal);
seedRandom (seed+1, true);
endVal = random (minVal, maxVal);
easeOut (time, segStart, segStart + segDur, startVal, endVal);

 

I'd appreciate someone's help without being to demanding :-)

 

Thanks a lot for reading this.

 

Chris

Paragraph align text with Expressions

$
0
0

Under paragraph menu, there is an option to align text to the left, center or right. There is also an option to justify text.

 

How can this me done with expressions or Extendscript?

 

 

I noticed that if I set Anchor point to the top left, additional text added on the same line is left aligned. If I set anchor point to the left-center, all the lines added in the future are left justified, but current text remains as it is. Align options under paragraph don't move anchor point and also work for the text already typed.

 

I guess you could save the text, delete it, move anchor point, paste the text back and move anchor point back where it was to achieve the same effect. But there is probably a better way?

Full auto-orient via expression

$
0
0

Hi!

 

I'd like a 3D Null to get the orientation of 3D a layer. (without parenting, it would be too easy )

 

I've tried a lot of solutions, through orientation, rotations, both combined... some results are close, but never perfect.

 

If I'm right, orientation is computed before rotations...

I think the simplest way would be with auto-orientation, or the lookAt() expression on orientation, wich gives me correct X and Y orientations, and then get an expression on zRotation to get a "full" orientation.

 

But what would it be?

How can I get the Z orientation in layer space?

 

Any idea will be appreciated!

 

François

Wiggle expression - slider control

$
0
0

Hi all

 

I had a solve for this from Dan Ebberts but I seem to have lost that content in the Jive update. I want to use a slider control for a wiggle, but when I have my basic wiggle expression applied to position, then pick whip from that to the slider, I get the below expression.

 

temp = effect("Wiggle Control Sliders")("Slider");

[temp, temp]

 

What is the fix for this/ way to do it right?

 

At the minute I'm using the expression below instead, but I hate not knowing the right way to do something! Using sliders/ creating decay in expressions has always been an issue for me...

 

wiggle(15,effect("Slider control")("Slider"))

 

Any help would be appreciated

 

Thanks!


Fade audio with expressions

$
0
0

Ok, I've taken an epxression for automactically fading opacity (which worked wonderfully) and tried to modify it to fade audio the same way.  Now, I get an error that says "After Effects warning: Expression Disabled. Error at line 0 in property....  expression result must be of dimension 2 not 1."

 

Here is the tweaked expression:

 

fadeTime = 30;

audio.audioLevelsMin = -50;

audio.audioLevelsMax = 0;

layerDuration = outPoint - inPoint;

singleFrame = thisComp.frameDuration;

 

animateIn = linear(time, inPoint, (inPoint + framesToTime(fadeTime)), audio.audioLevelsMin, audio.audioLevelsMax);

animateOut = linear(time, (outPoint - framesToTime(fadeTime+1)), (outPoint-singleFrame), audio.audioLevelsMax, audio.audioLevelsMin);

 

if(time < (layerDuration/2+inPoint)){

animateIn;

}else{

animateOut;

}

 

Now, opacity is a linear, 1 dimensional characteristic.  Why did that work and the updated expression for audio cause an error?

Advanced expression (position) question

$
0
0

I'm usually pretty good with expressions, but I'm really stumped on this one:

 

For the sake of keeping it simple, let's say I have:

1. A layer

2. A null object with a slider

 

I want my layer to slide in (x position only) from Point A, to Point B, pause on Point B for a few seconds, then slide back to Point A.

 

Here's the challenge: I want Point B to be controlled by the slider, but I always want Point A to be the same exact starting/ending point. (say 0, for the sake of simplicity). So the animation should go:

 

0 to X, then X back to 0, where X is the value driven by the slider.

 

Hope this makes sense. Thank you in advance to anyone who might be able to help.

Expression that references fill color and adds or subtracts brightness?

$
0
0

Hey,

 

I'm looking to create an expression that I can add to my bevel "highlight color" and "shadow color" that will reference the fill of a layer and automatically make it brighter by a bit (for highlight) and a version to make it a bit darker (for shadow).

 

I'm assuming I can pickwhip the fill, and then add to that or subtract from it (I'm presuming some sort of array that references the color value?), but I'm not trained enough in expressions to do that.

 

Thanks!

After Effects, Expression : Time + Slider Control (Time*effect("Slider Control")("Slider")

$
0
0

Hello,

 

First post here.

 

I'm having big troubles understanding what's wrong with my simple expression.

 

What i'm trying to achieve : I want to make a layer rotate with the time. Like this : Rotation = (Time*100)

So like this, at 1 second, the value of rotation will be 100°.

So far so good.

 

Then, I want to make this rotation stop, and control when it stops.

 

So i add a slider control.

I put the value on my slider control to 100, and change the expression on my rotation to : Time*effect("Slider Control")("Slider")

So right now, nothing changed.

But then i animate the value of my slider control. One value to 100, move forward in time, add another value to 0.

 

And now everything goes strange. My rotation goes in positive values and then, in the middle of it, change rotation and goes into negatives values...

 

I don't understand why it does this, specialy since taken separatly, both function are linear.

 

If you guys have an idea about this, this would be awesome!

Thanks a lot.

 

Loick

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

sourceRectAtTime() expression to change key-framed position of solid based on text layer width

$
0
0

Hello,

 

I am making a series of fully-customizable lower-thirds, that automatically scale / change based on the width of any given text layer. I have had success with linking the width of a shape layer to the width of a text layer using the following expression:

 

s=thisComp.layer("FIRST NAME")

x=s.sourceRectAtTime(time-s.inPoint,true).width;

[x, value[1]]

 

I also have a position expression linked to the size.

 

content("Rectangle 1").content("Rectangle Path 1").size/2

 

 

Here is my question:

 

If I want to link a key-framed "end position" of a shape layer to the width of a text layer, how would I go about that? Below is a video of my current animation. A square rolls in then splits in two to reveal text. I want the right half of the square to automatically animate further away based on the width of the text layer. My goal is to make this as user-friendly as possible, so even an 'After Effects Novice' can edit and export!

 

 

The shape layer in question has key-framed animation on both the x-scale, and the x-position. The keyframes are eased and velocity adjusted as below.

 

keyframe velocity.JPG

 

I do realize that I'll also have to write an expression to scale the Alpha Matte in relation to the width of the text layer (which should be similar to my first expression at the top), but that's nothing I can't handle.

 

Please Help!!!

Multiple checkbox related to each other with expressions Enquiry

$
0
0

Hello Guys,

Basically I need to do three colour options only one of them must be selected at a time so for example if I select Red colour then the other two options (Blue & Green) will be deselected automatically.

I've been trying quite hard to get this to work but I can't seems to figure it out alone.
Here's what I did.  3 checkbox controls, all in one layer (R, B, G) to control three colour or anything. And the rule for that is "if R checked in the box then the others un-checked at a time and vice versa".

The idea is a three way checkbox selection which coordinates with each other in the following way:

  • checkbox 1 - if ( (B ==1) || (G == 1)) false; else true;
  • checkbox 2 - if ( (R ==1) || (G == 1)) false; else true;
  • checkbox 3 - if ( (R ==1) || (B == 1)) false; else true;

It's seems like all work fine but when I checked the boxes nothing would change on the effected layer that I linked it with all checkboxes.
If you managed to understand what I'm trying to do, I'd love to hear your thoughts about this and what I am doing wrong.



I use this expression for each checkbox
R checkbox:

R = effect("R")("Checkbox"); T = effect("B")("Checkbox"); C = effect("G")("Checkbox");  if ((T == 1) || (C == 1)) {false} else  true;

B checkbox:

R = effect("R")("Checkbox"); T = effect("B")("Checkbox"); C = effect("G")("Checkbox");  if ((R == 1) || (C == 1)) {false} elsetrue;

G checkbox:

R = effect("R")("Checkbox"); T = effect("B")("Checkbox"); C = effect("G")("Checkbox");  if ((T == 1) || (R == 1)) {false} elsetrue;

The effected layer I did this rule:
Red = thisComp.layer("Red").effect("Fill")("Color"); Blue = thisComp.layer("blue").effect("Fill")("Color"); Green = thisComp.layer("Green").effect("Fill")("Color");  R = thisComp.layer("Controler").effect("R")("Checkbox"); B = thisComp.layer("Controler").effect("B")("Checkbox"); G = thisComp.layer("Controler").effect("G")("Checkbox");  if (R==1)  Red; else if (B==1) Blue; else if (G==1) Green; else value;

 

The project file in this link Project checkbox test


 


Limit value scale value using expression.

$
0
0

I'm using wiggle to scale a layer and I really only want it to wiggle  the scale in the positive direction (>100)
I looked into using an "if/else" statement, but AE always error-ed out.

 

This is what I'm using to wiggle the scale.

 

 

 

x=wiggle(effect("XTIME")("Slider"),effect("XDistance")("Slider"));

y=wiggle(effect("XTIME")("Slider"),effect("XDistance")("Slider"));

 

[x[0],y[0]]

 

I tried inserting this line of code, but it always error-ed

 

if (transform.scale[0] < 100) 100.2 else transform.scale[0]

 

Is it a syntax issue or am I just way off track. ANd I'm sure it's probably a really easy answer......

 

thanx in advance for your help

 

best,

 

Fred

Expression to duplicate whole layer several times.

$
0
0

Hi everyone,

 

I am pretty new with AE, I want to ask if there is an expression, which would let me duplicate selected layer?

I want to use expression, because I have to use like, 30 layers of same object, only with some position and rotation offsets.

 

THank you.

Floating Expression

$
0
0

Greetings community,

 

i found an expression that makes a floating animation with consistant oscillations.

 

xAmp = 3; //height of undulations (pixels)

xFreq = .3; //undulations per second

xSpeed = 150; //speed of wave (pixels per second)

 

wl = xSpeed/xFreq; //wavelength (pixels)

phaseOffset = ((position[0]%wl)/wl)*2*Math.PI;

y = xAmp*Math.sin(2*Math.PI*xFreq*time + phaseOffset);

value + [0,y]

 

This expression does the oscillations only on the Y axes.

 

My question:

Is there a way to make the expression do the oscillation not just on Y, but also on the X axes at the same time?

Expression to constantly change color of a spectrum

$
0
0

Hi,

I'm running a music channel where I upload music regularly, and I need an expression for the color effects on my audio spectrum layer (Inside Color/Outside color)

Basically, I need a way to keep this spectrum constantly changing in a rainbow form, if not I can put in my own colors if needed, if you don't understand what I mean look at the spectrum at the back of the black spectrum, I need an expression that can do that.

Bag Raiders - Shooting Stars (Onderkoffer Remix) - YouTube

Thanks In advance! Also it would be great if it smoothly blended into each color

 

How to use Expression to Mask Path vertices

$
0
0

Hi guys,

In Expression Language Reference(https://helpx.adobe.com/after-effects/using/expression-language-reference.html), I find an method called "points()";

 

and there is an example like:

  • Example 2

The example reads the coordinates of the first vertex of Mask 1 on Dark Gray Solid 1 and converts them to composition coordinates. Apply this to a 2D point control of an effect, such as Write-on or CC Particle Systems II, to make the effect trace or track the first point of an animated mask. Duplicate the effect and change the path points index value ([0]) to trace or track the other points of the mask.

myLayer = thisComp.layer(2);
myLayer.toComp(myLayer.mask("Mask 1").maskPath.points()[0]);

emm...

but when I try this, I get en error message saied:

points() method is undefined.....

So I confused about points() method,

 

Viewing all 47983 articles
Browse latest View live


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