Page 1 of 1

Linking opacity to xPosition ?

Posted: January 3rd, 2014, 5:53 am
by AdamHoej
Hi!

I tried to solve this, but I'm having some problems.. I want my object to fade from MinOpa -> MaxOpa, when the requirements are met.


I really hope someone can help me out here!
How it looks now with the code posted below..

Code: Select all

//Position//
ConPos = thisComp.layer("Controller").transform.position[0];
CircPos = transform.position[0];

//Opacity//
MaxOpa = 100;
MinOpa = 5;

//Controllers//
s = thisComp.layer("Controller").effect("Tolerance Slider")("Slider");

//EXPRESSION//

if (CircPos>ConPos+s || CircPos<ConPos-s)
{
MinOpa

}else{

MaxOpa
};

Re: Linking opacity to xPosition ?

Posted: January 4th, 2014, 10:19 am
by beginUndoGroup
Hi, you can try this:

Code: Select all

//EXPRESSION//
linear( Math.abs(ConPos-CircPos), 0, s, MaxOpa, MinOpa);
and also try replace linear by ease, or easeIn, or easeOut.

Xavier

Re: Linking opacity to xPosition ?

Posted: January 5th, 2014, 3:35 am
by AdamHoej
Thanks Xavier, that worked like a charm!


It all ended up like this

Code: Select all

//Position//
ConPos = thisComp.layer("Controller").transform.position[0];
CircPos = transform.position[0];

//Opacity//
MaxOpa = thisComp.layer("Controller").effect("Max Opacity")("Slider");
MinOpa = thisComp.layer("Controller").effect("Min Opacity")("Slider");

//Controllers//
s = thisComp.layer("Controller").effect("Tolerance Slider")("Slider");

//EXPRESSION//

ease( Math.abs(ConPos-CircPos), 0, s, MaxOpa, MinOpa);