Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How to overwrite position value with variable

New Here ,
Sep 11, 2014 Sep 11, 2014

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

TOPICS
Expressions
931
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 11, 2014 Sep 11, 2014

Try replacing the last line with this:

[value[0],value[1],z]

Dan

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 11, 2014 Sep 11, 2014

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 11, 2014 Sep 11, 2014

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 11, 2014 Sep 11, 2014

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...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 11, 2014 Sep 11, 2014

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 12, 2014 Sep 12, 2014

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 12, 2014 Sep 12, 2014
LATEST

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines