let say i has two object like picture A.
And i need move the cube toward the capsule and
it is require cube is parellel to the capsule. (like B)
How i can do it, i had success moved the cube to the capsule, but i can not figure out how i can make it parallel.
thanks you in advise.
Set their rotations such that they are parallel. The exact rotations to use will depend on your models, but, for example:
cube.transform.rotation = capsule.transform.rotation;
The easiest way is to define a rotation based on the cube, than Slerp the capsule to this rotation (the same can be done to position the capsule) - kind of:
var target: Transform; // drag the cube here
var offSet: Vector3(0,5,0); // distance to stop
var dock = false; // set this to true to start docking
var pos = target.position + target.TransformPoint(offSet);
var rot = target.rotation;
rot = rot * Quaternion.Euler(0,0,90); // see note
transform.rotation = Quaternion.Slerp(transform.rotation, rot, Time.deltaTime);
transform.position = Vector3.Lerp(transform.position, pos, Time.deltaTime);
NOTE: Set the Euler angles above to define the relative orientation of the capsule (it depends on the cube axes).