ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

comparing values of 2 angles == strange results ?

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Marticus Kilverticus
comparing values of 2 angles == strange results ?
on Mar 8, 2019 at 4:16:56 pm

Hi all,

Just found something strange I thought I'd ask if I was missing something.
I'm comparing 2 angle values, which when the same should trigger the next value.

qq = (thisComp.layer("layer1").effect("Angle Control")("Angle"))
ww = (effect("Angle Control")("Angle"))

if (ww == qq) 1; else 0


When == is used, it never seems to trigger the correct response even though both values are the same, switching to <= worked for me (luckily my angle will only ever be higher than the other one.
Anyone know if there's a reason for this? Am i using == wrong here?

Thanks


Return to posts index

Kalleheikki Kannisto
Re: comparing values of 2 angles == strange results ?
on Mar 8, 2019 at 4:24:47 pm

"==" has zero tolerance, so you might want to round the angles to the closest full degree or whatever tolerance is suitable for you needs.

Kalleheikki Kannisto
Senior Graphic Designer


Return to posts index

Marticus Kilverticus
Re: comparing values of 2 angles == strange results ?
on Mar 11, 2019 at 10:30:48 am

I get that, but the angles have been manually set to exactly the same value and I still get the same result...


Return to posts index


Dan Ebberts
Re: comparing values of 2 angles == strange results ?
on Mar 11, 2019 at 2:29:27 pm

Try it this way:

qq = thisComp.layer("layer1").effect("Angle Control")("Angle").value;
ww = effect("Angle Control")("Angle").value;

if (ww == qq) 1; else 0


Dan



Return to posts index

Marticus Kilverticus
Re: comparing values of 2 angles == strange results ?
on Mar 12, 2019 at 5:27:09 pm

Yep, adding .value to the referenced angle did it. Would love to know why!

Either way, lesson learnt, thanks Dan


Return to posts index

Dan Ebberts
Re: comparing values of 2 angles == strange results ?
on Mar 12, 2019 at 6:07:22 pm

When you do this:

qq = thisComp.layer("layer1").effect("Angle Control")("Angle")

you have set variable qq to be the Angle Control object. Sometimes you can get away with this and AE will assume you really want the value of that control, but not always. When in doubt, add .value.

Dan



Return to posts index

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