Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Magnetic Repel Expression – HELP !!!

  • Magnetic Repel Expression – HELP !!!

    Posted by Will Skinner on June 24, 2008 at 11:45 pm

    Hi

    Im trying to create the effect of a ‘slinky’.

    Ive tried using various expressions which have come close (spring, repel, position decays etc) but they arent quite working for me…

    I want to be able to move a ‘hero’ object left and right and the objects around it will move away but with a slight delay or elasticity. As the hero object is dragged away then the other objects will follow but with delay aswell.

    As i said, ive come close but the main issue is when objects cross over each other instead of repelling each other.

    Any help would be most appreciated…

    Will Skinner replied 17 years, 11 months ago 2 Members · 2 Replies
  • 2 Replies
  • Mike Clasby

    June 25, 2008 at 7:30 am

    Would need to see the expression(s) and the objects, methinks.

  • Will Skinner

    June 25, 2008 at 7:38 am

    The main expression i have used is this …

    restLength = 70;
    damp = 0.4;
    leader = thisComp.layer(“leader”);

    fDur = thisComp.frameDuration;
    currFrame = Math.round(time / fDur);

    p4 = position.valueAtTime(0);
    v2 = 0;
    for (f = 0; f <= currFrame; f++){ t = f*fDur; p1 = leader.transform.position.valueAtTime(t); delta = p4 - p1; nDelta = normalize(delta); a = 5 * nDelta * (length(delta) - restLength) * fDur; v2 = (v2 - a) * damp; p4 += v2; } p4 The comp consists of lots of thin vertical lines in a row. The above expression works fairly well when i move the 'leader' line left to right, the lines to its left follow with some delay and elasticity. However i want the lines that are to the right of the 'leader' line to to be repelled right as the leader gets nearer but so there is no cross over and the lines on the leaders right become more compressed together...but never touch.

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy