Expressions/Scripts/Presets

Moderators: Disciple, zlovatt

 
AdamHoej
Topic Author
Posts: 2
Joined: Fri Jan 03, 2014 3:56 am
Location: Aarhus - Denmark

Linking opacity to xPosition ?

Fri Jan 03, 2014 5:53 am

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..
//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
};
 
beginUndoGroup
Posts: 79
Joined: Tue Nov 27, 2012 6:41 am

Re: Linking opacity to xPosition ?

Sat Jan 04, 2014 10:19 am

Hi, you can try this:

//EXPRESSION//
linear( Math.abs(ConPos-CircPos), 0, s, MaxOpa, MinOpa);


and also try replace linear by ease, or easeIn, or easeOut.

Xavier
 
AdamHoej
Topic Author
Posts: 2
Joined: Fri Jan 03, 2014 3:56 am
Location: Aarhus - Denmark

Re: Linking opacity to xPosition ?

Sun Jan 05, 2014 3:35 am

Thanks Xavier, that worked like a charm!


It all ended up like this

//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);

Who is online

Users browsing this forum: No registered users and 3 guests