-
Distance traveled
Good afternoon!
I’m stuck on an expression.
I have a slider that is animated like a mileage counter. It starts at 0, has various accelerations and decelerations, and ends at 0.
I want a text layer to return the value of the distance traveled by reading the data from the slider that acts as an odometer.
I have tried several expressions but they all give me the same error, when the slider goes forward it works fine, but when it goes backwards the distance traveled also goes backwards, ending up at 0 again when the slider ends its animation at 0.
This is the expression that I have right now and it does what I have commented on.
Good afternoon!
I’m stuck on an expression.
var totalDistance = 0;
var lastRead = 0;
sliderCuentaKilometers = thisComp.layer(“Controls Journey”).effect(“Speed”)(“Slider”);
if (sliderCuentaKilometers >= lastRead) {
totalDistance += sliderCuentaKilometers – lastRead;
}
lastRead = sliderCuentaKilometers;
distanceTotal.toFixed(2);
I do not know how to do it…