Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions if/else – position

  • if/else – position

    Posted by Michał Chraper on March 27, 2018 at 8:56 am

    Hi,

    I’m trying to write expression that moves object as long as “speed” parameter is not equal to 0. I have no alert from AE about that code but it doesn’t do the job, nothing happens…

    speed = effect("Slider Control")("Slider");
    x = transform.position[0];
    y = transform.position[1];

    if (speed == 0) {[x, y]}
    else {[x + time*speed, y]}

    Michał Chraper replied 8 years, 5 months ago 2 Members · 3 Replies
  • 3 Replies
  • Dan Ebberts

    March 27, 2018 at 4:31 pm

    Animating speed in AE is not simple. This may be helpful:

    https://www.motionscript.com/articles/speed-control.html

    Dan

  • Michał Chraper

    March 28, 2018 at 9:31 am

    Thanks for respond Dan. Reading the article You quoted I understood where is the problem in my expression. I didn’t know that I can’t use “speed” word as variable name. Since I change it to “spd” shortcut expression started to work.

    Indeed it’s a bit complicated to control acceleration and deceleration but until you want to control constant speed, e.g. by slider control, it’s easy as my expression 😉

  • Michał Chraper

    March 28, 2018 at 9:36 am

    So, with little modification, working code looks like that…

    spd = effect("speed")("Slider");
    x = value[0];
    y = value[1];

    if (spd == 0) {[x, y]}
    else {[x + time*spd, y]}

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