One animation Two object

This video you see is from a point and click game called Tiny Thief. I want to do it with the ladder mechanics here. https://youtu.be/0fQM-xyoqFM

But as you can see in this video, it doesn’t seem to be done with a mechanic, a component like transform or rigidbody. An animation starts when the button is clicked. I have tried it myself. I created animation clips in Unity so that my object will only move on the y axis. But the problem there is that since the transform component consists of 3 components, the object moves on the x axis of the place I created it. I don’t know how to turn these two objects into a single animation.

it sounds like you perhaps animated the root of your character too.

Don’t animate the root of your character.

Instead, animate the child parts and move the character yourself from the root.

This is how walking (and indeed any locomotion) animations work. Obviously they don’t pre-make animations for every possible place you could walk.