Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Converting y position velocity to scale

  • Converting y position velocity to scale

    Posted by Wick Van den belt on November 20, 2014 at 7:11 pm

    Dear forum,

    I am looking for an expression to link the Y velocity of an object to another value.

    More specific.
    I have a Null object called ‘Bug Control’.
    On there I have a slider controlling the X Y scale of an object.
    How can I use the velocity value of a layer to increase the value of a slider controlling the scale when the velocity goes up, and decreasing when the velocity goes down again.

    Even More specific.
    The idea is that I have a round character that jumps up and down. I want the Y-Scale to down up and the X-scale to go up when the Y-position of the layer increases to create an automatic ‘Squeeze’ look when the character jumps.
    This could be very helpful when I have to edit in many jumps, to spare the amount of keyframes.

    I have tried several expressions that I think were really close but I couldnt get it to work properly.

    -When I get this concept I could basically also apply it to offset the position of a null object controlling the Y-position.. That could give a more organic look when the character jumps..

    I hope someone could help me out with this one.
    To show what I mean I have made a simple setup with a circle representing the character and added the EAP here :

    8207_expressionexample.aep.zip

    Thanks a lot!

    WickieMedia.net

    Graham Macfarlane replied 11 years, 5 months ago 2 Members · 3 Replies
  • 3 Replies
  • Graham Macfarlane

    November 21, 2014 at 12:23 pm

    What expressions have you tried so far?
    I use an older AE so I can’t open your project.

    Graham Macfarlane – CGI specialist
    Elyarch Ltd – London UK

    3D Studio Max | Vray | Pflow | PhoenixFD | After effects | Mocha

  • Wick Van den belt

    November 21, 2014 at 6:08 pm

    Hi Graham, I have been trying so many things but over-written all that I’ve used in the process..

    I guess the right way would be to either First get the velocity or speed of the Y-position, or an actual increase in Y position and map that to an increase in the value that the expression is added to with a Clamp.

    thisComp.layer(“BUG”).transform.yPosition.velocity;
    linear(velocity, 0, 10, 0, -10);

    I am really new to expressions so I’m really not sure what would be the right one here.
    I tried tweaking the squash and stretch expression from motionscript.com but also with a lot of tweaking that didn’t gave me the results I was looking for… I think that some else-if ideas and definitely some easing would really help sell the effect.. and well, in the worst case I end up keyframing it after all :))

    Any ideas here would be greatly appreciated!

    Cheers,

    Wick

    WickieMedia.net

  • Graham Macfarlane

    November 22, 2014 at 11:53 am

    I modified a script by Chris Wright which should give you something to work with. Put the script below into the scale of a null. The null must also have Y position keyframes for the jumping. Just pick whip your bug to the null and you should see the effect.
    My null started at 540 and rose up to 360 so in lines 2 and 3 you need to adjust the script for your specific null. The 50,0 and -50,0 control the amount of squash/stretch.

    Y = transform.position[1];
    Yresult = linear(Y, 360, 540, 50, 0);
    Xresult = linear(Y, 360, 540, -50, 0);

    // Inertial Bounce (moves settle into place after bouncing around a little)
    //By Chris Wright
    //Modified by Graham Macfarlane

    n = 0;
    if (position.numKeys > 0){
    n = position.nearestKey(time).index;
    if (position.key(n).time > time){
    n = n-1;
    }
    }
    if (n == 0){
    t = 0;
    }else{
    t = time - position.key(n).time;
    }
    if (n > 0){
    v = position.velocityAtTime(position.key(n).time - thisComp.frameDuration/10);
    amp = .02;
    freq = 3.0;
    decay = 5.0;
    s= v*amp*Math.sin(freq*t*2*Math.PI)/Math.exp(decay*t);
    value + [Xresult+s[1], Yresult-s[1]];

    }else{
    value;
    }

    Graham Macfarlane – CGI specialist
    Elyarch Ltd – London UK

    3D Studio Max | Vray | Pflow | PhoenixFD | After effects | Mocha

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