That’s encouraging!
I’ll share what I’ve got, it kind of works… so far at least.
The best I can get (with help from a robot friend and a sledge hammer) is below.
I’ve gone for 8 directions of walking.
So, on my character layer there’s a slider Slider effect called ‘Direction’ with this expression
// Store the current position
var currentPosition = position.value;
// Store the previous position
var previousPosition = position.valueAtTime(time - thisComp.frameDuration);
// Calculate the difference in position to determine the direction
var deltaX = currentPosition[0] - previousPosition[0];
var deltaY = currentPosition[1] - previousPosition[1];
var directionNumber = 0;
if (deltaX == 0 && deltaY == 0) {
directionNumber = 0; // No movement
} else {
var angle = Math.atan2(deltaY, deltaX) * 180 / Math.PI;
if (angle >= -22.5 && angle < 22.5) {
directionNumber = 4; // Right
} else if (angle >= 22.5 && angle < 67.5) {
directionNumber = 8; // Down-Right
} else if (angle >= 67.5 && angle < 112.5) {
directionNumber = 2; // Down
} else if (angle >= 112.5 && angle < 157.5) {
directionNumber = 7; // Down-Left
} else if (angle >= -67.5 && angle < -22.5) {
directionNumber = 6; // Up-Right
} else if (angle >= -112.5 && angle < -67.5) {
directionNumber = 1; // Up
} else if (angle >= -157.5 && angle < -112.5) {
directionNumber = 5; // Up-Left
} else {
directionNumber = 3; // Left
}
}
// Return the current position to avoid breaking the position expression
currentPosition;
// You can see the direction number in the slider
directionNumber;
and then in time remap
// Get the direction number from the Direction slider control
var directionNumber = effect("Direction")("Slider").value;
// Map the direction number to specific times
// Adjust these values based on your precomp timing
var timeMap = [0, 1, 2, 3, 4, 5, 6, 7, 8]; // Example times for each direction
// Return the corresponding time remap value
timeMap[Math.round(directionNumber)];
the time remap doesn’t give those numbers but its predictably wrong which is good enough, I guess !