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

X position extension around if/else statements

Community Beginner ,
Mar 24, 2021 Mar 24, 2021

Copy link to clipboard

Copied

Hello,

 

I'm working on a mogrt and have gotten stuck on how to add an option to extend the position around a series of if/else statements that I already have in place. The current series of statements controls optional build in/build out animation:

 

startBuilda = transform.xPosition.key(1).time;

startBuildb = transform.xPosition.key(2).time;

endBuilda = transform.xPosition.key(3).time;

endBuildb = transform.xPosition.key(4).time;

buildOne = thisComp.layer("Adjustment Layer 4").effect("build in")("Checkbox")

buildTwo = thisComp.layer("Adjustment Layer 4").effect("build out")("Checkbox")

moveIn = linear(time,startBuilda,startBuildb,1401,567.4);

moveOut = linear(time,endBuilda,endBuildb,0,1401); bothBuilds = moveIn + moveOut

 

if (buildOne == true && buildTwo == true) bothBuilds + extendTR

else if (buildOne == true) moveIn

else if (buildOne == false && buildTwo == true) transform.xPosition.key(2) + moveOut

else if (buildOne == false && buildTwo == false) 567.4

 

I want to integrate the code below so that whatever state is occuring through the if/else statements, the position extension can occur:

 

regOn = thisComp.layer("Adjustment Layer 4").effect("regOn")("Checkbox")

extend = thisComp.layer("Adjustment Layer 4").effect("Extend")("Checkbox")

 

if (extend == true && regOn == true) 500

else 567.4

 

What would be the best way to go about this? The things I've tried have not been working and I feel like it's probably something pretty obvious.

 

Thanks!

TOPICS
Expressions

Views

131

Translate

Translate

Report

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
LEGEND ,
Mar 24, 2021 Mar 24, 2021

Copy link to clipboard

Copied

Your code is a mess to begin with due to not being properly formatted and of course you are not doing any actual nesting/ branching, hence the conditionals basically do nothing because one of the test conditions is always met, hence it's basicalyl always set to tru. You need to obey operator precedence and add more structure by nesting the if statements along with cleaning up the code by defining variables and reusing them instead of always writing out the full functions.

 

Mylenium

Votes

Translate

Translate

Report

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 Beginner ,
Mar 24, 2021 Mar 24, 2021

Copy link to clipboard

Copied

LATEST

Maybe the formatting didn't translate properly when I copied and pasted, but so far as I understand everything, it is all correct. Here's a screenshot that shows all the indentations for the if/else statements, plus all of the variables that I've created:

 

Screen Shot 2021-03-24 at 11.32.41 AM.png

 

For nesting/braching, do you mean turning the if/else statements into their own variables? Or something else?

 

Thanks,

 

J

Votes

Translate

Translate

Report

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