It’s called inverse kinematics. If you want to do it yourself, check out the Animation Rigging package of Unity (and search for tutorials) or if you want more turn-key solutions, I recommend to check out FinalIK and/or Puppetmaster on the Asset Store, they are great and mature packages and contain everything you ever need to setup your interaction systems.
Yes, Im aware of IK, this is definitely part of it. What about the aspect of having 2 separate animations that need to be aligned spatially and synchronized? If we ignore IK for now, how does this work? How can you have 2 separate characters with 2 separate animators come together to perform together (petting a dog, the person animation with the dogs reaction, or if the door has animation that syncs with a character opening it, etc)?
I’m not sure what you’re asking, because it is too vague. It depends. You need to manage to move your actors into positions. What are the positions? It depends on the action you’re trying to play back. How you move them? It depends how you’re handling movement in your application and what kind of animations you have and intend to use. But in general you should have relative positions to each other tailored to the actual interaction you are trying to play back.
Then you need either animations or code to drive the IK chains to make the interaction properly. They you need to go back to some generic position to release and go back to either player control or some sort of AI control.
In general, you can choose to have animations and animation events to drive your interactions along with purposefully placed colliders and triggers and have signals to make sure your game logic knows where the animations are.
Or you can have completely code generated movement and drive the animation from the code part, this needs planning, a bunch of math (vectors, rotations, knowledge about IKs).
There is no magic, you plan what will happen, make a plan how the interaction will take place and do it. Either make/buy/whatever animations and/or write the code it makes and then handles it.
The FinalIK/PuppetMaster are almost magic. In reality it’s just that the publisher already wrote a big chunk of code you would have to.