Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions How to call for a value before expression?

  • How to call for a value before expression?

    Posted by Simon Björk on December 30, 2010 at 10:05 am

    I’m trying to reposition a camera to start at z-position 0.

    For example, I have a camera that has a position of [960,549,-8000].

    I want to move the z-position to 0, so I add the following expression “position + [0,0,transform.position[2]*-1]”. I can’t call the actual value, becuse this expression will be a part of an autumated process and the camera position will be different for different projects. All this works perfectly, but I have some other obects that I want to move the same ammount. For example, I have a null at z-position 10, and would like to move that the same ammount as the camera (which would give me a value of 8010 in this example.

    I tried with the following expression to the null: “position + [0,0,thisComp.layer(“Camera 1″).transform.position[2]]”, but that doesn’t work since the cameras z-position has been moved to 0 already. So I must call the cameras original z-position somehow. Is this possible?

    Dan Ebberts replied 15 years, 7 months ago 3 Members · 5 Replies
  • 5 Replies
  • Chris Wright

    December 30, 2010 at 6:28 pm

    put this in null position.

    r=thisComp.layer(“Camera 1”).transform.position.valueAtTime(effect(“Slider Control”)(“Slider”));

    value+[0,0,r[2]];

    https://technicolorsoftware.hostzi.com/

  • Simon Björk

    December 30, 2010 at 8:24 pm

    Thank you for your reply Chris, but nothing happens with that expression, even if I add a slider to the null. Am I supposed to change any values?

  • Dan Ebberts

    December 30, 2010 at 8:29 pm

    Try this little trick. Change your camera’s expression to this:

    if (time < 0)
    value
    else
    position + [0,0,transform.position[2]*-1];

    and the null’s expression to this:

    position + [0,0,thisComp.layer(“Camera 1”).transform.position.valueAtTime(-1)[2]]

    Dan

  • Simon Björk

    January 4, 2011 at 9:35 am

    Hi Dan, thanks for your reply.

    I don’t get your expression to work either.

    It does change the nulls position correctly if I change your “position + [0,0,thisComp.layer(“Camera 1″).transform.position.valueAtTime(-1)[2]]” to position + “[0,0,thisComp.layer(“Camera 1″).transform.position.valueAtTime(-1)[2]*-1]”.

    However, I I want to animate my camera, I can’t. If I use the z-slider, it just moves the null and snap back to position 0.

    Any ideas?

  • Dan Ebberts

    January 4, 2011 at 4:05 pm

    Ah, OK. I didn’t understand that you were animating the camera. Try it this way:

    camera:

    if (time < 0)
    valueAtTime(-time)
    else
    position + [0,0,transform.position[2]*-1];

    null:

    position + [0,0,thisComp.layer(“Camera 1”).transform.position.valueAtTime(-time)[2]]

    Dan

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