Creative Communities of the World Forums

The peer to peer support community for media production professionals.

  • Posted by Aaron Pozzer on September 1, 2011 at 3:15 pm

    I have this expression controlling the opacity of a layer…

    C = thisComp.activeCamera;
    startFade = 0;
    endFade = 100;
    d = length(toWorld(anchorPoint),C.toWorld([0,0,0]));

    linear(d,startFade, endFade, 20,80)

    … to control the opacity based on how far away the camera is to the layer. it works fine with the camera in the same comp. i then wanted to use this same expression inside a precomp, but refrencing the same camera in the main comp. so i went into the precomp, selected the opacity of the layer i wanted to control, pasted the expression and changed it to this…

    C = comp(“Map”).activeCamera;
    startFade = 0;… etc

    …which isnt working. Im guessing it has something to do with the toWorld part, and it might need toComp in there somewhere since the camera is not in the precomp.

    suggestions? thanks!

    Aaron Pozzer replied 14 years, 11 months ago 2 Members · 4 Replies
  • 4 Replies
  • Dan Ebberts

    September 1, 2011 at 4:48 pm

    You need to do the toWorld() thing twice: first to get your layer into its comp world space, and then to get that value into the main comp’s world space. It will look like this (not tested):

    C = comp(“Map”).activeCamera;
    L = comp(“Map”).layer(thisComp.name);
    startFade = 0;
    endFade = 100;
    p = toWorld(anchorPoint);
    d = length(L.toWorld(p),C.toWorld([0,0,0]));
    linear(d,startFade, endFade, 20,80)

    The precomp needs to be a 3D layer in the main comp.

    Dan

  • Aaron Pozzer

    September 1, 2011 at 8:28 pm

    thanks Dan, as always that worked. took me a few tries to figure out what thisComp.name was refering to, but i got it.

    you were helping me with another issue a few months back and its come back to haunt me again. i posted up again last week, but im not sure if you saw it. if you wouldnt mind having a look here…

    https://forums.creativecow.net/readpost/227/18903

    … that would be great.

    thanks again Dan!

  • Dan Ebberts

    September 1, 2011 at 9:39 pm

    Sorry, it’s really hard to diagnose (for me at least) without seeing it.

    Dan

  • Aaron Pozzer

    September 3, 2011 at 3:04 am

    s’ok dan, i think i found a solution by switching from using a stroke effect to using a particle emitter that draws a line. this also gives me the option to raise the line up off the map. it also had the unexpected side effect of fixing the problem in the other thread…

    but now i have a new issue. ill post it in a new thread.

    thanks

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