Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by primaerfunktion · Jul 12, 2019 at 04:24 PM · animationmecanimfbxsynchronization

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;
 
     [Header("Diff")]
     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].clip.name;
             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].clip.name;
             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

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image JamesB ♦♦ · Jul 15, 2019 at 09:00 AM 0
Share

Hello there, can you confirm a few things for me: 1. Both Animator components have the same Update $$anonymous$$ode. 2. Both AnimationClips have the exact same number of frames (not just same duration). 3. Both Animator components have the same speed. 4. Both Animation States have the same speed.

On a similar note, if you want to have clips play simultaneously you might want to consider Timeline ins$$anonymous$$d of manually controlling Animators, it's designed for doing pretty much exactly this.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by primaerfunktion · Jul 15, 2019 at 09:34 AM

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.

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image JamesB ♦♦ · Jul 15, 2019 at 09:46 AM 0
Share

Is it possible that the difference in frame counts is causing the error that you are seeing? Do the animations definitely sync up (in Blender)? Is it possible that the triggering of these animations is happening on different frames?

avatar image primaerfunktion JamesB ♦♦ · Jul 15, 2019 at 09:48 AM 0
Share

Will need to investigate if it's actually the Frame count causing this, but don't have access to the project till tomorrow. Feel like it would be a bit strange though.

They do sync up in Blender and start at the same time at Frame 0.

avatar image JamesB ♦♦ primaerfunktion · Jul 15, 2019 at 09:52 AM 0
Share

What I mean by start at the same time, is the call to animator.SetTrigger() at the same time (not from separate Update calls or something)?

Show more comments

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

351 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Mecanim muscle system overrides T-pose 0 Answers

How can I stick feet? 0 Answers

my animation isnt importing, and the mesh stays on the T pose 0 Answers

Animations panel: changing one keyframe value makes the other keyframes have the same value 0 Answers

How do I put duplicated, modified animation clip into original model? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges