Copy link to clipboard
Copied
Is it possible to overwrite a specific value with a value of a variable from my expression?
My expression (I thought I could use):
"z = transform.position[2]-thisComp.layer("Audioamplitude").effect("Beide Kanäle")("Schieberegler");
transform.position[2] = z;"
But AE claims that the Z-Position Value of my layer (camera) is read-only...
I want to have jumps in my camera synced to musik so the amplitude value should be substracted from my Z-position value but if I dont overwrite the "old" value then the camera obviously jumps back to the original position.
Thanks in advance for any answer
Copy link to clipboard
Copied
Try replacing the last line with this:
[value[0],value[1],z]
Dan
Copy link to clipboard
Copied
yeah but then I have the problem that it jumps back to the original Z-value minus the new amplitude value so it isn't continuous "zooming out" but with jumps in the speed as I want it to
Copy link to clipboard
Copied
Ah, OK--I get it. Unfortunately, that's a lot more complicated. There's no way for an expression to pass variable information from one frame to the next. It has to go back and re-calculate everything that has happened in the past, up to the current frame. Try this:
a = thisComp.layer("Audioamplitude").effect("Beide Kanäle")("Schieberegler");
mult = 10;
f0 = timeToFrames(inPoint);
f = timeToFrames(time);
accum = 0;
for (i = f0; i <= f; i++) accum += a.valueAtTime(framesToTime(i));
value - [0,0,accum*mult]
Adjust the mult variable to control how fast it zooms out.
Dan
Copy link to clipboard
Copied
ok thx as I try to understand the time bit there is still one problem - I have to set the multiplicator to an extremely low value (0.03) to fit my initial position of the camera - but then the "jumps" are not noticable at all...
Copy link to clipboard
Copied
Try changing this line:
for (i = f0; i <= f; i++) accum += a.valueAtTime(framesToTime(i));
to this:
for (i = f0; i < f; i++) accum += a.valueAtTime(framesToTime(i));
Dan
Copy link to clipboard
Copied
ok it is like... better but still my question is why isn't it possible to overwrite the value - then you could just work with the new value for the next frame without a ten line expression
Copy link to clipboard
Copied
You'd have to ask the Adobe engineers, but my understanding is that variables can't persist because AE is stateless, which means that you can drop the play head anywhere and that frame will render correctly, which wouldn't work if persistent variables were allowed.
Dan
Find more inspiration, events, and resources on the new Adobe Community
Explore Now