# Adjust postion only in X axis

I have two game objects named A and B, just as follows:

I want to move object B to this virtual line without any rotation so that the destination is B' . What I have are transformation of object A and B. I'm brand new to Unity3D and its APIs, so I don't know how should I get this done.

• You want to translate object B towards the red line or just instantaneously place it on the red line ?? – Hash Buoy Sep 17 '15 at 9:19
• I want to project/translate B onto the line. – frogatto Sep 17 '15 at 9:25
• @HashBuoy I've edited my question to be more clear. Please take a look. – frogatto Sep 17 '15 at 9:36

B.transform.parent = A.transform;