# How do I find out the interval/space between two array children?

i think i worded it wrong in the title but im making a weird rhythm game and i have the song’s notes mapped on an array
like when the notes play

example: [1.2, 3.6, 4.8, 6], the numbers are in seconds

i know its kind of a horrible way to program it but its just for a concept
how would i get the intervals of these numbers?
like the time it takes for it to move onto the next one basically?

I’m not sure if I understand but if you’re talking about the difference between 2 children then

Say the variable index was the index (or child number) and note is the array

Set Interval to note[index] - note[index - 1]

IDK how you want to treat the note[0] Is it’s interval zero or the value in it. Or you could leave note[0] as 0 and start at note[1] You just need to make sure you don’t try to get note[0] - note[0-1]

I think he needs to subtract from greater note instead from lesser one or he will end up with negative value
Or maybe use abs expression

It all depends on which index you want. You just need to subtract the smaller value from the larger or like ZeroX4, you can use abs() to get the absolute value.

Abs(10-5) is 5
Abs(5-10) is also 5. Abs() makes everything positive.

Just be sure each child exists.

thanks! ill try this out later today