Copy link to clipboard
Copied
i tried manipulate one layer's property by another layer that is being manipulated too and it didn't work.
I'll explain:
I had layerA that it's position value is being manipulated by an expression, and I wanted layerB opacity to turn 100% on if layerA position[0] is greater than 0. It didn't work. but when I turned off layerA expression and changed it's position manually, it did work.
I have the impression that layerB opacity expression is looking at the original value and not at the manipulated one.
Is it correct? is there any way making the expression look at the manipulated value?
Copy link to clipboard
Copied
An expression on one property only has access to the post-expression value of another property, so I suspect you're misinterpreting what's going on. What do the two expressions look like?
Copy link to clipboard
Copied
The expression on layerB Position is an array of values which is picked by the numbers on another layers' markers.
(It might sound familiar because you took a big part in building this template I'm working on, solving all the riddles I couldn't decipher 😅).
This is the full expression both layers have on their position:
m = comp("ASA_LL_sky_UI").layer("Click controller B").marker.key(2).comment;
const cm = comp("ASA_LL_sky_UI").layer("Click controller B").marker;
const catM = comp("ASA_LL_sky_UI").layer("Sky CAT controller").marker;
let latestMarkerIndex = 0;
if (catM.numKeys > 0) {
latestMarkerIndex = cm.nearestKey(time).index;
if (cm.key(latestMarkerIndex).time > time) {
latestMarkerIndex--;
}
}
let outputText = "";
if (latestMarkerIndex > 0) {
const latestMarker = cm.key(latestMarkerIndex);
outputText = latestMarker.comment;
};
menus = comp("ASA_LL_sky_UI").layer("Sky CAT controller").effect(2)("Menu").value;
yVals = [371,634,896,1157,1416,1684,1950,2208,2470,2730,2995,3254,3515,3781,4038];
m = outputText-1;
y = yVals[menus-1];
result = [
[ 159.0632 , y ],
[ 349.0632 , y ],
[ 540.0632 , y ],
[ 731.0632 , y ],
[ 920.0632 , y ]
];
result[m];
Copy link to clipboard
Copied
What's layer B's opacity expression?
Copy link to clipboard
Copied
cB = this comp.layer("B").transform.position[0];
cB > -120 ? 100 : 0;
Copy link to clipboard
Copied
I'm confused. In your original post you mentioned that layer B's opacity expression was looking at layer A's position, but the opacity expression you just posted doesn't have a reference to layer A.
Copy link to clipboard
Copied
Yep, you are right.
I wrote it the opposite way on my first post...
So according to the explanation on the first post, it suppose to be written that way:
cA = this comp.layer("A").transform.position[0];
cA > -120 ? 100 : 0;
Copy link to clipboard
Copied
At this point I'm afraid it would be hard to diagnose the issue without seeing the actual project file.
Copy link to clipboard
Copied
So it seems like I have found a solution.
I wrote in the opacity property the same code as in the position, and added the if else statement at the end of it:
(in this code, layer A's opacity is looking at layer B's position to know when to turn off. when layer B's position[0] > -120, layer A's opacity will turn 0%)
m = comp("ASA_LL_sky_UI").layer("Click controller B").marker.key(2).comment;
const cm = comp("ASA_LL_sky_UI").layer("Click controller B").marker;
const catM = comp("ASA_LL_sky_UI").layer("Sky CAT controller").marker;
let latestMarkerIndex = 0;
if (catM.numKeys > 0) {
latestMarkerIndex = cm.nearestKey(time).index;
if (cm.key(latestMarkerIndex).time > time) {
latestMarkerIndex--;
}
}
let outputText = "";
if (latestMarkerIndex > 0) {
const latestMarker = cm.key(latestMarkerIndex);
outputText = latestMarker.comment;
};
menus = comp("ASA_LL_sky_UI").layer("Sky CAT controller").effect(2)("Menu").value;
yVals = [371,634,896,1157,1416,1684,1950,2208,2470,2730,2995,3254,3515,3781,4038];
m = outputText-1;
y = yVals[menus-1];
result = [
[ 159.0632 , y ],
[ 349.0632 , y ],
[ 540.0632 , y ],
[ 731.0632 , y ],
[ 920.0632 , y ]
];
result[m];
cB = thisComp.layer("B").transform.position[0];
cB > -120 ? "0" : "100";
I hope it won't cause troubles anyhow later or..
But I'm still curious to know what prevented this code from working...
Copy link to clipboard
Copied
In that configuration, only the last two lines have any effect on the outcome, so if it works like that, you should be able to get rid of all the code above those two lines.
Copy link to clipboard
Copied
Ghost layer?!
This is so weird. It still didn't work when I deleted all the code above the last two lines, so I tried rendering the frame and the layer disappeared from the rendered image
Copy link to clipboard
Copied
Sorry, I rendered it once more and it appears again..