Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Why on earth does this value[0] not work?

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

    Posted by Marc Walker on August 4, 2016 at 1:04 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;
    }

    Dan Ebberts replied 9 years, 11 months ago 2 Members · 5 Replies
  • 5 Replies
  • Dan Ebberts

    August 4, 2016 at 3:19 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

  • Marc Walker

    August 4, 2016 at 12:09 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

  • Dan Ebberts

    August 4, 2016 at 1:15 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

  • Marc Walker

    August 5, 2016 at 2:59 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

  • Dan Ebberts

    August 5, 2016 at 3:16 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

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