I have three synchronised animations in three files, and I play them in sync at the start of the scene and then also later in the scene. However I can't seem to get them to sync in the later stage. My transitions throughout are all triggers, and each has its own controller. I tried the .animator.ResetTrigger("myTriggerNames") approach on all three. Even after immediately calling the Reset trigger and then triggering the desired animations on all three objects, I sill have them way out of sync. Anyone have any "one size fits all" objective advice for getting them in sync? Thanks
You can always force a sync by calling Animator.Play(0,-1, currentTime); Using 0 as the first parameter tell the animator to change the time of the current state without triggering OnStateEnter. The idea is to have a master animator, which you can poll the current state time and use it to drive the two slave animator. Or you could try to trigger the tree animation togheter from the same Update function with Code (CSharp): void Update() { if(startSyncAnim) { Animator1.Play(myfirstanimstate,-1, 0); Animator2.Play(mysecondanimstate,-1, 0); Animator3.Play(mythridanimstate,-1, 0); } }
This helped me in 2019! I think most of the time, using transition in the animator would probably be fine but for synchronizing animations to start on 2 (or more) objects at once, the animator.Play method worked so much better for me. Thank you.
I found this post when searching for my problem and it's sort of relevant. I wanted my animators to always be in sync. So every time I set an animator parameter, I want multiple animators to receive the same parameter value. I created this simple script called AnimatorSynchroniser which you can attach to your gameobject. In your scripts, instead of referencing the Animator component, reference the AnimatorSynchroniser and you can set your parameters for all the Animators in 1 call. example: Code (CSharp): GetComponent<AnimatorSynchroniser>().SetFloat("speed", 2f); It's pretty basic atm, but it can easy be extended just by creating a wrapper for the different animator functions like I've done already. Hopefully this helps someone! AnimatorSynchroniser.cs Code (CSharp): using UnityEngine; public class AnimatorSynchroniser : MonoBehaviour { public Animator[] animators; private void Start() { //Assumes all Animator components are children //You can change this or remove this line and assign your animators in the inspector animators = GetComponentsInChildren<Animator>(); } //Set a boolean parameter for all animators public void SetBool(string name, bool value) { foreach (Animator anim in animators) { anim.SetBool(name, value); } } //Set a float parameter for all animators public void SetFloat(string name, float value) { foreach (Animator anim in animators) { anim.SetFloat(name, value); } } //Set an integer parameter for all animators public void SetInteger(string name, int value) { foreach (Animator anim in animators) { anim.SetInteger(name, value); } } //Set a trigger parameter for all animators public void SetTrigger(string name) { foreach (Animator anim in animators) { anim.SetTrigger(name); } } //The get functions just return the first animators value - no point looping here public bool GetBool(string name) { return animators[0].GetBool(name); } public float GetFloat(string name) { return animators[0].GetFloat(name); } public int GetInteger(string name) { return animators[0].GetInteger(name); } }
I tried to use this same approach of playing the animation on Update but still not works. Is there another solution? One of my animations is always some frames forward than the other no matter what I do or how I call them.
Still having this problem in 2019.4.11f1. I've been trying to set up two separate Game Objects each with an Animator component, both using a different Animator Controller Override based on the exact same Animator Controller. The Controller has multiple layers, including an additive layer. All the parameters sent to both animators are always being sent at the exact same frame. I have tried the solutions listed above, and multiple variants (notably: using CrossFade, iterating through the layers to call Play() on each layer, calling Update(0f) on the animators every frame after these modifications). Nothing I do seems to work, there's always a slight delay between both animators.
This is great, but doesnt work well with sub-states, the state inside the sub-state remains unsynced. Is there a way to force a sync on sub-states as well? Nvm, figured it out pretty much right away Shouldnt use 0 as a first parameter, but should instead use the master's current state hash, i.e. Code (CSharp): void Update() { for (int i = 0; i < toAnim.layerCount; i++) { toAnim.Play(fromAnim.GetCurrentAnimatorStateInfo(i).fullPathHash, i, fromAnim.GetCurrentAnimatorStateInfo(i).normalizedTime); toAnim.SetLayerWeight(i, fromAnim.GetLayerWeight(i)); } } Actually, theres another problem, is that this approach doesnt support transition blending. How do we fix that?
use animator.Update(0f); to sync up after using animator.play() as unity waits a internal update step to start playing
Hello. You can refer to these steps: Go to the Articulate tab on the PowerPoint ribbon and click Narration. Click Sync Animations on the ribbon. As the slide's narration plays, click Next Animation each time you want an animation to occur. cupcake 2048
I tried the other solutions and they were just slightly off. This one honestly for some reason is off too (like animations are at different points) but it works way better than the other ones for me. Thanks.