- Home /
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. :P
Answer by sparkzbarca · Nov 21, 2012 at 04:46 PM
figured it out.
cross of 2 normals rotated to be parallel.
Answer by Montraydavis · Oct 13, 2012 at 03:31 PM
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.
IE:
.Rotate ( ) .LookAt ( ) ; etc.....
Your answer
Follow this Question
Related Questions
Camera Script - RtS style, rotation issues 0 Answers
Problems with rotation script. 2 Answers
Z rotation locks to certain value randomly? 0 Answers
door script problems 2 Answers
Make ball flip around cube... 0 Answers