FORUMS: list search recent posts

Why on earth does this value[0] not work?

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Marc Walker
Why on earth does this value[0] not work?
on Aug 4, 2016 at 1:04:58 am

Why on earth does this value[0] not work?

It's like it won't update. It works if I replace the value[0] with pos1[0].

Thanks, Marc W.

var pos1 = thisComp.layer("Pos. Light.1").toComp([0,0,0]);
var pos2 = thisComp.layer("Pos. Light.2").toComp([0,0,0]);

if ( value[0] > 640)
{
value = pos1;
}
else
{
value = pos2;
}


Return to posts index

Dan Ebberts
Re: Why on earth does this value[0] not work?
on Aug 4, 2016 at 3:19:56 am

value[0] should give you the pre-expression x value of the property hosting the expression. Is that not what you're seeing?


Dan



Return to posts index

Marc Walker
Re: Why on earth does this value[0] not work?
on Aug 4, 2016 at 12:09:30 pm

Hi Dan,
It's strange (to me) because if value was (716, 384) say, the if statement seems to work at first (when I click out of expression box), but then it doesn't change over time, it just stays the same when value[0] passes around 640.

It's like it doesn't run the if statement for each frame basically. I haven't read anywhere that this is the correct behavior for value. Is it? and if so, what could I use instead of value[0]?

Thanks


Return to posts index


Dan Ebberts
Re: Why on earth does this value[0] not work?
on Aug 4, 2016 at 1:15:46 pm

The only way value will change is if you are animating it with keyframes. I'm guessing you're not doing that, is that correct?

The expression itself has no effect on value (at least not within that expression), it will always be what you would get if the expression was turned off.

There are workarounds, but it depends on what you're trying to do.

Dan



Return to posts index

Marc Walker
Re: Why on earth does this value[0] not work?
on Aug 5, 2016 at 2:59:15 pm

No, I don't have any keyframes on that property.

I'll try to show you exactly what I'm trying to do, maybe that will help you to help me.
This is my comp:
This shape image turns on two axes(TIFF seq), and the lights follow the "points" of the shape in 3D(extracted from Cinema4D):


I use the light points as markers for lightening strike points(`Direction` property).



As you can see in the above image, In order for the lightening to strike the light points, I added two effects (`Pos X Offst` of 640px and `Pos Y Offst` of 360px) and also applied to the `Direction` property, the expression
thisComp.layer("Pos. Light.1").toComp([0,0,0]);

So we get to now... and all I want is for the lightening not to strike the light point if the light point passes the halfway point of the screen in either dimension, but instead, to switch to another light point. This is as far as I got because of the problem in the OP. I was going to add more code to the expression so that the lightening will eventually strike the closest light point (within tolerance).

I hope this has explained a bit more for you and not confused you instead!

Thanks


Return to posts index

Dan Ebberts
Re: Why on earth does this value[0] not work?
on Aug 5, 2016 at 3:16:34 pm

I'm still confused. In your expression, value[0] is referring to the x value of the Direction property. If you're not animation that property via keyframes, value[0] will never change. Shouldn't the "if" part of the expression be using the position of the lights instead?


Dan



Return to posts index

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