Question by
ErikHallmarkDev · Feb 02, 2017 at 06:46 PM ·
vector3snapping
Snap vector to axis
I have a somewhat odd problem that maybe you can help me with. I would like to have a function which can take in two vectors, let's call them A & B, and it should return a vector which is 90 degrees perpendicular to vector A, and as close to vector B as possible.
Basically I want a function which snaps vector B to being 90 degrees perpendicular to vector A.
Any idea on how I can accomplish that?
Comment
Answer by hexagonius · Feb 03, 2017 at 10:24 AM
you can use the cross product (Vector3.Cross) twice:
- using it with A and B it it gives a vector C perpendicular to both.
- using it again with A and C it's still perpendicular to A but pointing into direction of B, being the closest distance to it
Your answer
