Animating motion with expression sliders
Hello,
I'm trying to simulate a pnuematic piston system for a tutorial at work. The system is a piston with 2 valves triggered by a controller and fed by seperate pressure regulators.
There are quite a few moving parts, but the important bit is I'm trying animate just the PSI sliders (effectively my speed) and Channel # checkboxes (on/off switches for each direction of motion).
I'm looking it the x position of the poston from one previous frame. When I trigger one of the check boxes it moves correctly for one frame and then freezes in that spot. If I key it on, then off, it goes back to its original position. I feel like looking for the previous frame value always just finds the original value.
Any suggestions?
Thanks!
var master = thisComp.layer("Master Control");
var pressureLeft = master.effect("PSI - Left")("Slider");
var pressureRight = master.effect("PSI - Right")("Slider") * 1.1;
var ch1 = master.effect("Channel 1")("Checkbox");
var ch2 = master.effect("Channel 2")("Checkbox");
var modifier = master.effect("Piston Speed Modifier")("Slider")
var previous = transform.xPosition.valueAtTime(time - thisComp.frameDuration);
if (ch1 == 0){
pressureLeft = 0
}
if (ch2 == 0){
pressureRight = 0
}
var difference = pressureLeft - pressureRight;
var movement = previous + difference * modifier
clamp(movement , 1149.6 , 862.6)


