make child object move at same speed as parent object

ive got a big carrier spaceship and a small fighter jet, trying to make it such that when the small ship gets inside the big one it acts like a person in a bus, so that if the big ship moves the small one will move too and be at a relative velocity of 0 with the big one, and also the small ship should be able to move around freely inside the big ship while the latter is moving

how do i do that?

The logic goes like:

When the fighter jet gets inside the ship then make the ship parent of the fighter jet.

Also use Transform.localPosition() to move the fighter jet so that when it is child of ship it will move relative to the ship and when on his own will move relative to the world space.

roughly this should work:

1.create an empty gameobject
2.add boxcollider component
3.set it to isTrigger
4.attach it to mother ships entrance position
5.write the transform.localposition code in its ontrigger method