Two Animators don't play in Sync

Hey guys,

we have an issue with the unity animator and we need your help.

We want to play a scenario, where two animators play at the same time their animations. For two characters to interact with each other. For this we need a frame perfect playback. And there is the issue.

We figured out that one Animator plays faster than the other, but the Animator and AnimationClip speeds are the same. Also the frame-rate for both clips are at 30fps.

We’re using the Unity Animator and call the animations via Trigger-Parameters. The FBX files are exported from Blender.

Has anyone of you faced the same issue before?
Do you have any advice?

Please find attached our profiling script, that we wrote to check the delay in detail and a Screenshot of the result.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CompareAnimationFrame : MonoBehaviour
    public Animator first;
    public string currentAnimFirst;
    public float currentFrameFirst;
    public float animatorSpeedFirst;
    public float currentFrameRateFirst;
    public Animator second;
    public string currentAnimSecond;
    public float currentFrameSecond;
    public float currentFrameRateSecond;
    public float animatorSpeedSecond;

    public float diffSpeed = 0f;
    public float diffFrames = 0f;

    private float firstDelta = 0f;
    private float secondDelta = 0f;

    private float firstLastTime = 0f;
    private float secondLastTime = 0f;

    private void Update()
        if (first)
            currentAnimFirst = first.GetCurrentAnimatorClipInfo(0)[0];
            currentFrameFirst = first.GetCurrentAnimatorStateInfo(0).normalizedTime * first.GetCurrentAnimatorClipInfo(0)[0].clip.frameRate;

            firstDelta = Mathf.Abs(first.GetCurrentAnimatorStateInfo(0).normalizedTime - firstLastTime);
            animatorSpeedFirst = firstDelta;
            currentFrameRateFirst = first.GetCurrentAnimatorClipInfo(0)[0].clip.frameRate;

            firstLastTime = first.GetCurrentAnimatorStateInfo(0).normalizedTime;

        if (second)
            currentAnimSecond = second.GetCurrentAnimatorClipInfo(0)[0];
            currentFrameSecond = second.GetCurrentAnimatorStateInfo(0).normalizedTime * second.GetCurrentAnimatorClipInfo(0)[0].clip.frameRate;

            secondDelta = Mathf.Abs(second.GetCurrentAnimatorStateInfo(0).normalizedTime - secondLastTime);
            animatorSpeedSecond = secondDelta;
            currentFrameRateSecond = second.GetCurrentAnimatorClipInfo(0)[0].clip.frameRate;

            secondLastTime = second.GetCurrentAnimatorStateInfo(0).normalizedTime;

        diffFrames = Mathf.Abs(currentFrameFirst - currentFrameSecond);
        diffSpeed = Mathf.Abs(firstDelta - secondDelta);

alt text

Hey @JamesB, thanks for replying.

  1. Both animators Update Mode is set to the same. We tried Normal and Fixed Time, with the same results.
  2. They actually don’t have the same Frame number.
  3. Both Animator Speeds are at 1.
  4. Also the States are set to 1.

So the only thing seems to be the difference in Frame number. But do you think that would result in that sort of difference?

Also, you are right, Timelines seem to be way to go actually. But would be nice it we could make it work with the current setup. Although it doesn’t seem achievable at the moment.