Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Making objects change position while within range of a camera

  • Making objects change position while within range of a camera

    Posted by Twelvizm on March 23, 2007 at 1:04 pm

    Think Pop-up targets.

    I’m going for an expression that will make objects go from horizontal to vertical while within the visible area of an animated camera.

    Any ideas?

    Darby Edelen replied 19 years, 1 month ago 2 Members · 1 Reply
  • 1 Reply
  • Darby Edelen

    March 23, 2007 at 5:33 pm

    You could use an expression to convert the object’s 3D coordinates to 2D screen (Comp) space and then rotate the layer based on how far it has traveled beyond a threshold value ‘left’ in this case:

    left = 150; //The distance in pixels from the left side of the comp when the layer begins to rotate
    right = thisComp.width – left; //The distance in pixels from the right side of the comp when the layer begins to rotate back
    duration = 50; //The distance in pixels that the layer will need to travel beyond the threshold for the rotation to reach the ‘end’ angle
    start = -90; //The angle to begin the rotation from
    end = 0; //The angle to rotate to

    angle = start;

    x = thisLayer.toComp(anchorPoint)[0]; //Transform this layer’s 3D Coords into its 2D coords and use the X value only

    //If we’ve passed the ‘left’ side but haven’t reached the ‘right’ side yet
    if((x >= left)&&(x <= right)){ angle = ease(x, left, left + duration, start, end); //ease from the 'start' to 'end' angle as the x value increases from 'left' to 'left + duration' } if(x > right){
    angle = ease(x, right, right + duration, end, start); //ease from the ‘end’ to ‘start’ angle as the x value increases from ‘right’ to ‘right +duration’
    }

    angle; //return the angle

    That should work!

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