this kind of works, but the transition and pause duration are not dynamic…
// Set the duration of each transition and pause period in seconds
transitionDuration = 2;
pauseDuration = 2;
// Define the start and end layer indices
startLayerIndex = 3; // Change this to match the index of the starting layer
endLayerIndex = 7; // Change this to match the index of the ending layer
// Calculate the total number of transitions
totalTransitions = endLayerIndex - startLayerIndex;
// Calculate the current transition index based on the current time
currentTransitionIndex = Math.min(Math.floor((time - inPoint) / (transitionDuration + pauseDuration)), totalTransitions - 1);
// Calculate the start and end layers for the current transition
startLayer = thisComp.layer(startLayerIndex + currentTransitionIndex);
endLayer = thisComp.layer(startLayerIndex + currentTransitionIndex + 1);
startPos = startLayer.transform.position;
endPos = endLayer.transform.position;
// Calculate the time elapsed since the start of the current transition
transitionStartTime = currentTransitionIndex * (transitionDuration + pauseDuration);
transitionElapsedTime = time - inPoint - transitionStartTime;
// Use an ease function to animate from the start position to the end position
ease(transitionElapsedTime, 0, transitionDuration, startPos, endPos);