rotating an object so the face nearest another objects face is parallel

basically i feel like i’m really close but i cant quite get the math part.


I have honestly spent hours and I can get the same face everytime to line up but not a different face. this code lines up the same face every time.

forward = Vector3.Cross(selection.right,-snap_hit_nearby.normal);

selection.transform.rotation = Quaternion.LookRotation(forward,-snap_hit_nearby.normal);

I think maybe selection.right isn’t supposed to be right its supposed to a variable direction but i’m a little lost.

I have a house trained, basic command knowing border collie i’d be willing to trade for the answer. :stuck_out_tongue:

First, just search through the objects you have, and find which is nearest, or initialize this data if it’s static. Afterwards, then transform.position.rotation.y = nearestObject.transform.rotation.y -(or +) 90 ; You can find much better and efficient rotating methods by searching Rotate in the Unity3D Documentation.


.Rotate ( )
.LookAt ( ) ;

figured it out.

cross of 2 normals rotated to be parallel.