Search Unity

Question Synchronize to note tap and note destruction (with lerp) | Rhythm Game

Discussion in 'Scripting' started by miko_2007, May 10, 2023.

  1. miko_2007

    miko_2007

    Joined:
    Sep 3, 2022
    Posts:
    1
    I don't know if I understand myself, I have this code that works quite well, the notes fall precisely to the target but they stop there, what I want to achieve is that the note reached the collider at the correct time but that it keeps going down until it exits the screen and end up destroying the note. Some help?


    Code (CSharp):
    1. void Update() {
    2.         float time = (Conductor.instance.beatsShownInAdvance - (beatOfThisNote - Conductor.instance.songPositionInBeats)) / Conductor.instance.beatsShownInAdvance;
    3.        
    4.         Vector2 position = Vector2.Lerp(spawnPosition, tapPosition, time);
    5.         transform.position = position;
    6. }