Highlighted

Why can't I get my expression to work?

Community Beginner ,
Nov 11, 2020

Copy link to clipboard

Copied

I added the proper keyframes to the position layer. But when I play the animation, nothing happens. Am I supposed to enable something in the settings?

This is the code:

nearestKeyIndex = 0;

if (numKeys > 0){

nearestKeyIndex = nearestKey(time).index;

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

nearestKeyIndex--;

}

}

if (nearestKeyIndex == 0) {

currentTime = 0;

} else {

currentTime = time - key(nearestKeyIndex).time;

}

if (nearestKeyIndex > 0 && currentTime < 1) {

calculatedVelocity = velocityAtTime(key(nearestKeyIndex).time - thisComp.frameDuration / 10);

amplitude = 0.1;

frequency = 2.0;

decay = 4.0;

value + calculatedVelocity * amplitude * Math.sin(frequency * currentTime * 2 * Math.PI) / Math.exp(decay * currentTime);

} else {

value;

}

 

v expression.jpg

The layer with the keyframes and expression input open.
TOPICS
Expressions

Views

47

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Why can't I get my expression to work?

Community Beginner ,
Nov 11, 2020

Copy link to clipboard

Copied

I added the proper keyframes to the position layer. But when I play the animation, nothing happens. Am I supposed to enable something in the settings?

This is the code:

nearestKeyIndex = 0;

if (numKeys > 0){

nearestKeyIndex = nearestKey(time).index;

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

nearestKeyIndex--;

}

}

if (nearestKeyIndex == 0) {

currentTime = 0;

} else {

currentTime = time - key(nearestKeyIndex).time;

}

if (nearestKeyIndex > 0 && currentTime < 1) {

calculatedVelocity = velocityAtTime(key(nearestKeyIndex).time - thisComp.frameDuration / 10);

amplitude = 0.1;

frequency = 2.0;

decay = 4.0;

value + calculatedVelocity * amplitude * Math.sin(frequency * currentTime * 2 * Math.PI) / Math.exp(decay * currentTime);

} else {

value;

}

 

v expression.jpg

The layer with the keyframes and expression input open.
TOPICS
Expressions

Views

48

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Nov 11, 2020 0
Guide ,
Nov 11, 2020

Copy link to clipboard

Copied

It works for me. How far apart are your keyframes in value and time? What does it look like in the graph editor (value)?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 11, 2020 0
Community Beginner ,
Nov 12, 2020

Copy link to clipboard

Copied

The keyframes are only a second apart. There is practically nothing going on in the graph editor.

graph editor.jpg

These are the letters I am trying to animate:

vibe.jpg

I am animating each letter one at a time. They are individual objects. I'm just focusing on the V right now, but they will all have the same effect, just different timing. I imported all of the objects from Illustrator. Do think that there is something wrong with the objects themselves?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 12, 2020 0
Guide ,
Nov 12, 2020

Copy link to clipboard

Copied

The expression is depending on the keyframes to establish the motion. The expression will generate the overshoot and oscillation, but it is based on the velocity coming into the second keyframe. From the graph editor, it appears that your keyframes may have the same value and aren't generating any motion. You should have the keyframes set for the start and end postions, and then apply the exprssion to generate the overshoot.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 12, 2020 0
Adobe Community Professional ,
Nov 11, 2020

Copy link to clipboard

Copied

Are you sure your keyframes have different values? also what is the time between these 2 keyframes, mostly you will not notice the spring effect if your animation is to slow, try to speed up your animation 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 11, 2020 0
Community Beginner ,
Nov 12, 2020

Copy link to clipboard

Copied

What do you mean by different values? All I do is copy and paste the expression in the input layer. I'm new to AE, so I'm trying to figure a lot of things out.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 12, 2020 0
Adobe Community Professional ,
Nov 11, 2020

Copy link to clipboard

Copied

As the others have pointed out, this expression creates a bounce when motion stops. If the motion is very small or the motion is slow, the bounce is very small. If the motion is fast and moves a long way, the bounce is bigger. With the expression disabled you should get no bounce and the layer should move. If the layer doesn't move then the value of the two keyframes is the same.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 11, 2020 0
Community Beginner ,
Nov 12, 2020

Copy link to clipboard

Copied

How would you know if the expression is disabled?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 12, 2020 0
Mylenium LATEST
Most Valuable Participant ,
Nov 12, 2020

Copy link to clipboard

Copied

As the others said already, there simply appears to be not enough motion in your setup, so the expression at best calculates some sub-pixel jitter. As for your other questions it might help if you actually started reading the help instead of blindly following whatever tutorials.

 

After Effects User Guide

 

Mylenium

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 12, 2020 0