Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Speed Activated Walk Cycle

  • Speed Activated Walk Cycle

    Posted by Duncan Catterall on March 18, 2014 at 4:08 pm

    Hi there,

    I’m trying to create a walk cycle which is activated by the speed expression. have managed to trigger my loop cycle from the speed expression but when it stops I need it to return to a decent rest position. Currently I have two legs which move at opposite rotations and this is applied to one of those legs (relating to the motion of the body).

    Code so far (applied to one leg’s rotation):

    Bod = thisComp.layer(“Body”).transform.position.speed;
    if (Bod >10) loopOut(“pingpong”); else 4;

    At rest the rotation value is 4, but I’d like at any point when my walker stops for it to get to this value smoothly rather than jumping straight to the rotation value 4. A half way house might be an expression to freeze where the walk is, but as it may look odd for a rest position to be mid-walk I’d rather it gets to a particular value.

    I’m just starting to use expressions, but I’m keen to try and make an environment in after effects that eventually has many characters walking around that will avoid each other, stop etc and it would be good to set up a fairly intelligent basis for walking and stopping without key framing dozens of characters.

    Any and all help gratefully welcomed.

    Many thanks,
    Dunc

    Bod = thisComp.layer("Body").transform.position.speed;
    if (Bod >10) loopOut("pingpong"); else 4;

    Duncan Catterall replied 12 years, 2 months ago 2 Members · 3 Replies
  • 3 Replies
  • Dan Ebberts

    March 18, 2014 at 6:46 pm

    What you’re trying to do is a little tricky. Your expression, if the speed is less than the threshold, will need to go backwards from the current time, frame-by-frame to find out how long it has been since the speed value was above the threshold. Then you would use that time to drive an ease() or linear() to move to your desired hold value. You’d also need a test to stop looking if it gets back to time = 0 without finding a frame where the speed went from above the threshold to below the threshold. The idea is very similar to the “beat detector” part of this:

    https://www.motionscript.com/design-guide/audio-trigger.html

    except you would be looking for a transition that goes from above to below.

    Dan

  • Duncan Catterall

    March 19, 2014 at 8:48 am

    Brilliant, thanks Dan I’ll give this a go and let you know how I get on 🙂

  • Duncan Catterall

    March 20, 2014 at 9:53 am

    I think I might be missing a trick here, mainly I as I’m pretty new at expressions. Just the rewritten code based on your decaying method but I’m getting errors back. Obviously if the value is above 10 then I want it to activate the loop cycle.

    Thoughts gratefully recieved 🙂

    threshold = 10.0;

    Bod = thisComp.layer(“Body”).transform.position.speed;

    below = false;
    frame = Math.round(time / thisComp.frameDuration);
    while (true){
    t = frame * thisComp.frameDuration;
    if (below){
    if (Bod.valueAtTime(t) < threshold){
    frame++;
    break;
    }
    }else if (Bod.valueAtTime(t) >= threshold){
    below = true;
    }
    if (frame == 0){
    break;
    }
    frame–
    }
    if (! below){
    t = 0;
    }else{
    t = time – frame * thisComp.frameDuration;
    }

    loopOut(“pingpong”)


    threshold = 10.0;

    Bod = thisComp.layer("Body").transform.position.speed;

    below = false;
    frame = Math.round(time / thisComp.frameDuration);
    while (true){
    t = frame * thisComp.frameDuration;
    if (below){
    if (Bod.valueAtTime(t) &lt; threshold){
    frame++;
    break;
    }
    }else if (Bod.valueAtTime(t) >= threshold){
    below = true;
    }
    if (frame == 0){
    break;
    }
    frame--
    }
    if (! below){
    t = 0;
    }else{
    t = time - frame * thisComp.frameDuration;
    }

    loopOut("pingpong")

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