Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Time Music and UI to be in sync (parallel/beat matches UI)

Discussion in 'Audio & Video' started by ClaudiaTheDev, Apr 23, 2022.

  1. ClaudiaTheDev

    ClaudiaTheDev

    Joined:
    Jan 28, 2018
    Posts:
    331
    In my game i have a small music mini game in which you have to press direction buttons to a music playing. (The base concept is similar to Dance Dance Revolution ot Stepmania, but of course more simple).
    Here is a gif so you know what i talk about:

    WIP_MusicMiniGame2.gif


    No my problem:
    I want to get sure that the music is timed to the UI (so the arrows match the specific beats). I managed to do it and it works "fine" but there are some issues occuring in both of my potential solutions.

    Attempt 1:
    I update the music and UI in Update based of the overall time passed (Time.delta).
    This results in the music stuttering a lot and some strange sounds, so it's not usuable. The UI works fine in this solution.
    upload_2022-4-23_9-26-45.png
    Audio:
    upload_2022-4-23_9-13-15.png
    UI:
    upload_2022-4-23_9-22-47.png

    Attempt 2:
    I update the UI based on the music time passed, also in the Update function. This results in the UI (arrows) stuttering a bit (you see this one in the gif). It's still better than attempt 1 because the music works fine. Still not super usuable because it feels like the UI is lagging to the player.

    upload_2022-4-23_9-14-3.png
    (UI same like above)

    Can anyone give me maybe some advice on this? Is maybe the Update function not the correct timing? Any other ideas?

    Because it's only a side mini game i already consider just playing the music and only updating the UI with Time.delta and hoping that it will stay in sync (beat/parallel).