How to get child object on top of his parent.

Hello.

I have a little problem with position of my child object. I will try to explain it on example.

76713-exmp-2.png
76714-exmp-3.png

I want to merge two objects into one (when they collide one of them became child of main object). So if they collide from top side this child object should be postion on top of the parent postion. But now it looks like on the 2nd picture. My code so far:

childObject.transform.SetParent (parentObject.transform);
childObject.transform.position = parentObject.transform.position;  

I tried to get height of parent object and set that postion but I think I do it wrong :confused: So can anyone help me how to get that?

I dont want to seem rude but your doing it all wrong

your script sets position

but there are other things that needs changing

Like,

The rotation (in Quaternion format)

The Scale

Etc.

 childObject.transform.SetParent (parentObject.transform);
 childObject.transform = parentObject.transform;