Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Question Synchronizing Animation to Music

Discussion in 'Animation' started by keinerFuerAlle, Jan 7, 2022.

  1. keinerFuerAlle


    Apr 24, 2020
    Hey there,

    I am currently struggling with a problem, about which it seems I just cannot find useful information online...
    What I am trying to do is to adjust the timing of my animation to the beat of some music that is playing in my game (trying to build a rythm game).
    For a first reference, I used this post:
    The last section is about manually setting the animation playback to the correct position according to the music.
    So I can use this line of code to set the animation to the correct playback position in each Update-call (which works fine so far).
    Code (CSharp):
    1. animator.Play(currentState, -1, normalizedPlaybackPosition);
    Yet, my problem is, that I just don't know, how to make transitions between animations.
    It seems, that when I call the Animator.Play() function in each iteration of the Update method, the Animators Transitions just won't get triggered.

    I would like to use the AnimatorController as usual, and just adjust the playback position within each animation manually to be in sync with the music...

    Any ideas on how I could achieve this (or some knowledge on what the problem is) is very appreciated!

    Thanks in advance for any advice ;)