Using CSV times to perform eases
- March 24, 2024
- 1 reply
- 1383 views
Hi! I've been trying to work out how to create a racing leaderboard in after effects that's driven by a CSV (an image of this is shown below).
The sheet below has the following columns:
P1: a random racer's position in the order
P2: another random racer (we'll ignore them for the time being)
SecInt: conversion of minutes, seconds, and milliseconds to decimal seconds
The racer positions are meant to be displayed using a text box, and I want it to ease every time there's an overtake (as indicated by the times on the timer). I wrote a bunch of code that was borrowed from one of my previous projects, but I can't seem to make it work.
Here's the code I have right now inside the source text of P1's position:
OT = footage("Placements.csv");
genData = footage("General Data.csv");
var numbering = ?; // This must be manually set!
var rowNum = 1;
var rowCount = genData.dataValue([1, 8]);
var output;
function easeTo (A, B, C, D) {
var output = ease(time, A, B, C, D);
return Math.round(output);
}
while (rowNum < rowCount)
{
//Step 1: Setting the Variables
startTime = OT.dataValue([4, rowNum]);
endTime = OT.dataValue([4, rowNum]) + 1/5;
prevPos = OT.dataValue([4 + numbering, rowNum - 1]);
newPos = OT.dataValue([4 + numbering, rowNum]);
//Step 2: Creating the Ease
while (time < endTime)
{
output = easeTo (startTime, endTime, prevPos, newPos);
}
//Step 3: Increment + Return to Start
rowNum++;
}
[output]
Note: I have a separate area (in `generalData`) that allows me to enter the number of rows in the CSV. I don't need to have it run infinitely.