ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

How to use length in if statement

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
tom ono
How to use length in if statement
on May 13, 2020 at 7:00:17 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)&lt;=100){
lookAt(target.transform.position,transform.position);
}


Return to posts index

Scott McGee
Re: How to use length in if statement
on May 13, 2020 at 8:01:43 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);
}


Return to posts index

Andrei Popa
Re: How to use length in if statement
on May 13, 2020 at 8:56:05 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.


Return to posts index


tom ono
Re: How to use length in if statement
on May 14, 2020 at 6:06:54 am

It works.
Thank you for giving me good advice.


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2020 CreativeCOW.net All Rights Reserved
[TOP]