How to automatically position characters in a "paired animation"

So, I got those animations in the Unity Store and they work fine if the character are aligned perfectly, however, I want to do those animations with the player and the npc, I already got the script to play an animation when the player presses a specific key and is close enough to the npc, my problem here is aligning them because I have no idea, as I am a beginner on Unity (Not on c# though). Maybe using IK? Would appreaciate some help as even chatgpt didnt help me out here haha.

Aligned and non aligned animations gifs attached bellow.

9440741--1324394--aligned.gif
9440741--1324397--notAligned.gif

You will most likely have to ‘slide’ the characters to the correct position/offset so that the motions match.

You can store the offset required for this animation pair, and then move either character to the proper spot using Vector3.MoveTowards or Vector3.Lerp.

You can also achieve a similar/same result as using TargetMatching, you’d still need to know the offset, and most likely move the Root target. This however requires RootMotion to be enabled IIRC.

The thing is, imagine the npcs are just wandering around, theres no way to hardcode all the positions so I’m still trying to know how I’ll do it.

You don’t hardcode a position, you hardcode an offset.

Hugging position requires that CharacterA and CharacterB are standing 1.25 meters in front of each other for the animation to ‘fit’.

Let’s say you’ll use CharacterA position as the ‘anchor’ for the animation to play.
You’ll then start the animation, and quickly slide CharacterB so that his position is CharacterA position + offset for the animation to play correctly.

1 Like