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 amExpression 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 amI’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 amI 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 amIt works.
Thank you for giving me good advice.
Log in to reply.