Animating 2 objects in sync with separate animators without parenting

Hey guys,

So I have a player character and an enemy character both having their own animators and a bunch of animations (this is a 2D game with sprites btw) … it all works great but now I wanted to do a God of War style mini game/ QTE. I keep wondering though how to animate them in sync. I tried making a parent object for both and putting an animator on that too but that really messes up my gameplay otherwise … and also my whole project started collapsing … references got removed, animations glitching … this was when I coded in that when the mini game is triggered the parents would change for both characters but the animator doesn’t read the objects properly and doen’t initiate my animation. Also if a child has an animator I cant select that child in the animation window… I have to remove the animator, animate then add the animator again.

Then I tried making them children of the parent object permanently but then realized I’d have to change my whole movement code which I prefer not to do and also doing that made all my previous animations bug out … since the animator couldn’t find the baby objects. I’m thinking of now making each of them animate separately through bools but I’m not sure if the animations will activate, blend and play at the same time in sync.

So just wondering if you guys can throw any ideas around on how this could be achieved. Thanks in advance!

I’m not sure exactly how, or for how long, you want the animations to sync, but it shouldn’t be too difficult to achieve if the animations themselves are compatible.
Simply use the same event to trigger both animations.

For example, if I want character A and character B to both punch at the same time, I can use A.anim.SetTrigger(“Punch”); and B.anim.SetTrigger(“Punch”); in the same function. If the Sprite animations are the same duration, and transitions are the same, they will play in unison.

Ok guys I figured it out. In my case what I did is probably too complicated and there might be an easier solution out there but this totally worked for me.

So I created duplicates of both my character and removed all the colliders, scripts and anything unnecessary from the objects and their child objects. Then I parented them under a single object with a script. I constantly move the parent objects position to one of the original characters position so that I know where the new duplicates will appear.

In the script I call all the SpriteRenderers on my duplicates (rough script) …
`
SpriteRendered objA;

void Start() {
objA = GetComponentsInChildren();
}

void FunctionName(){
if (conditionIsTrue){
foreach (SpriteRenderer s in ObjA){
s.enabled = false;
}
}
}`

do the same for second object and while re-enabling. Also, I added the code that when re-enabling the original objects I move the original objects to where the transforms of their duplicates are at the time. So it all works smoothly. If anyone else needs more info just ask.

Cheers.