Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Forums Adobe After Effects Expressions How to use length in if statement

  • How to use length in if statement

  • tom ono

    May 13, 2020 at 7:00 am

    Expression tells “undefined variable used in expression”
    If there is not if statement,it works.
    I used text source so that I make sure if length(s) was recognized.
    Length(s) was recognised.

    I want to know what is wrong. thanks.

    target=thisComp.layer("circle");
    s = sub(target.transform.position,transform.position);
    if(length(s)<=100){
    lookAt(target.transform.position,transform.position);
    }

  • Scott McGee

    May 13, 2020 at 8:01 am

    I’m not sure what you are trying to do with the lookAt, as I’ve never used it before. But it works fine in text source.

    target=thisComp.layer(“circle”);
    s = sub(target.transform.position,transform.position);
    if(length(s)>=100){
    lookAt(target.transform.position,transform.position);
    }

  • Andrei Popa

    May 13, 2020 at 8:56 am

    I think you also need to give it a value if the distance is greater.


    target=thisComp.layer("Circle");
    s = sub(target.transform.position,transform.position);
    if(length(s) <= 100){
    lookAt(target.transform.position,transform.position);
    }else{
    value
    }

    Andrei
    My Envato portfolio.

  • tom ono

    May 14, 2020 at 6:06 am

    It works.
    Thank you for giving me good advice.

Viewing 1 - 4 of 4 posts

Log in to reply.

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