• Global community
• Language:
• Deutsch
• English
• EspaÃ±ol
• FranÃ§ais
• PortuguÃªs
• æ—¥æœ¬èªžã‚³ãƒŸãƒ¥ãƒ‹ãƒ†ã‚£
Dedicated community for Japanese speakers
• í•œêµ­ ì»¤ë®¤ë‹ˆí‹°
Dedicated community for Korean speakers
Exit
• How can I fix this expression?

# How can I fix this expression?

Explorer ,
Aug 28, 2024 Aug 28, 2024

Copied

Could someone help me with this expression. I am trying to get a position to bounce up and down with easing. The other requirement is that the oscillation should occur with the original position in the middle (so that when I adjust the sliders to zero, the position returns to where it was).

This is all part of an expression based animation. However - I'm having this issue where the easing occurs in the middle. So it slows down as it approaches the middle from it's peak. See video. It should be two smooth movements instead of three.  Any ideas @Dan Ebberts ?

``````var ctrl = thisComp.layer("Controller");
var bounceHeight = ctrl.effect("Bounce Height")("Slider");
var bounceSpeed = ctrl.effect("Bounce Speed")("Slider");

// Get the original position of the layer
var originalPos = transform.position;

// Calculate time-based phase for the bounce
var t = time * bounceSpeed;

// Create a time loop for continuous bouncing
var loopTime = 2 * Math.PI; // One full oscillation period
var loopProgress = (t % loopTime) / loopTime; // Normalized progress within one period

// Apply easing function to create a smooth bounce effect
var easedProgress = ease(loopProgress, 0, 1, 0, 1); // Eases from 0 to 1

// Calculate the vertical position with a bounce effect and easing
var bounceY = originalPos[1] + Math.sin(easedProgress * Math.PI * 2) * bounceHeight;

// Maintain the original X position
var bounceX = originalPos[0];

// Set the new position
[bounceX, bounceY];``````

TOPICS
Expressions

Views

63

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Community Expert ,
Aug 29, 2024 Aug 29, 2024

Copied

LATEST

I think the ease is messing things up. If you just use loopProgress instead of easedProgress, does that give you what you want?