Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Z Rotation based on camera proximity??

  • Z Rotation based on camera proximity??

    Posted by Brian Charles on December 19, 2007 at 6:47 pm

    I’m clearly missing something critical. Any assitance will be gratefully appreciated.

    I’ve tried the following expression:

    startR =150// start rotation 150 pixels from camera
    endR = 0; // end rotation 0 pixels from camera
    C= thisComp.activeCamera;
    P = length(toWorld(anchorPoint),C.toWorld([0,0,0]));
    linear(P,startR,endR,0,-20)//0 degrees at start minus 20 at end

    This yields odd results though I can’t see my error. The layer rotates but the distance from the camera isn’t accurate. In fact the layer starts in the rotated position and rotates to 0 as the camera approaches…

    Thanks.

    Brian Charles replied 18 years, 8 months ago 2 Members · 3 Replies
  • 3 Replies
  • Mike Clasby

    December 19, 2007 at 7:10 pm

    Trying your expression, the distances work for me; with x and y equal for camera and rotating layer, when the z gets within 150 pixels it makes the rotating layer start to rotate.

    The only change I can see is to switch the 0, and -20 to make the last line this:

    linear(P,startR,endR,-20,0)//0 degrees at start minus 20 at end

    That works in a test.

  • Brian Charles

    December 19, 2007 at 7:10 pm

    I’d reversed the values in the final line…. Doh!

    With some assistance from Adobe Expression reference:

    startR = 800; //start rotation 800 pixels from camera
    endR = 300; //end rotation 300 pixels from camera
    C = thisCoe.activeCamera.toWorld([0,0,0]);
    P = toWorld(anchorPoint);
    d = length(C,P);
    linear(d,startR,endR,-20,0)

  • Brian Charles

    December 19, 2007 at 7:12 pm

    Thanks Mike. While you were posting I had some caffiene and my discovered my error as well.

    Many thanks.

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