I would like to ask you about the judgment processing method related to music games.
I'm programming to compare the timing determined for each note (example: 6.0 seconds from the start of the song) with the current time that has passed since the start of the song, and perform judgment processing based on the difference, but the one I'm currently using ( (Shown below) to "Absolute value by Mathf.Abs<= (timing of each note)" or "(Timing of each note) plus or minus 〇 seconds and compare the current time", and note within a certain range I would like to be able to process. However, even if I want to use these smart formats, it will not work due to the errors described later.

Code in use
if (notetim --timer<= -0.05/* lower limit * /&&notetim -timer>= -0.1/* upper limit * /) {
// notetim: Time fixed for each note (not -1.6)
// Addendum 2020/11/18: notetim is the time determined for each note.
// -1.6 is a variable used in another script that generates notes.
// It is -1.6 so that it comes to the center of the judgment line.
// timer: The elapsed time from the start of the song
 // Make a perfect/miss judgment here
Error etc.

This works for the time being, but it is judged only in a very narrow range and it becomes an extremely strict judgment. It's nice to be a little behind the center of the line, but I want to expand this judgment range to the upper side because I want to make the judgment area itself quite wide. Therefore, if you change the upper limit value for that purpose, it will move up and down in this very narrow area, and you will not be able to expand the range.
Also, I set the position of the lower limit first, thinking "If so, should I decide the lower limit first and then decide the upper limit with the if statement?", But an error appears as out of range at the location of the Destroy function. .. In connection with this, the same phenomenon occurs when the process of returning a mistake and erasing the note when it goes out of this specific range is added.

I want to achieve

I want to create a wide judgment area by changing the contents of the if statement and returning the judgment processing when the button is pressed within plus or minus 0 seconds from the original timing.

Usage environment Unity2019.1.51f Visual Studio

Postscript (2020/11/18)
Since the explanation of the variable was incorrect, the relevant part was added and corrected.

  • Answer # 1

    "Notetim: Time fixed for each note-1.6" → Isn't it necessary to calculate here?

    First, the effective range is shown by variables. (The following is an example where the slower tolerance is larger)
    Perfect is based on the "time determined for each note", and OK is based on the "lower and upper limits of perfect".

    Perfect lower limitperfectMin: -0.1

    Perfect upper limitperfectMax: +0.2

    Lower limit of OKokMin: -0.2

    OK upper limitokMax: +0.4

    Make this a code.
    timerIs the current time,noteIs "a fixed time for each note".
    This is because "the current time should be within each lower and upper limit based on the" time determined for each note "".

    if (note + perfectMin<timer&&timer<note + perfectMax) {
        // Processing at the time of perfection
    } else if (note + perfectMin + okMin<timer&&timer<note + perfectMax + okMax) {
        // Processing when OK
    } else {
        // Processing in case of mistake

    For example, if note = 6 and timer = 6.3,
    (5.9<6.3&&6.3<6.2)Is false, so it's not perfect.
    (5.7<6.3&&6.3<6.6)Is true, so it is within the OK range, so I think it will work as expected.
    All you have to do is adjust the value so that the tolerance is wider.

    Destroy's error is "There is no item with that number in the array", so
    I'm trying to erase the notes before reading them (= before putting the data in the array)
    I think the cause is that you are trying to erase more elements than the number of elements in the array.
    If you google with the error sentence, various information will come out, so please check it together with the above. (If you still don't understand, please enter the code of the relevant part)