Answers for "Find Vector3 perpendicular to Vector3 A in direction of Vector3 B"http://answers.unity.com/questions/730156/find-vector3-perpendicular-to-vector3-a-in-directi.html
The latest answers for the question "Find Vector3 perpendicular to Vector3 A in direction of Vector3 B"Answer by Bunny83http://answers.unity.com/answers/730174/view.html
You just need to project your vector B onto the plane with the normal vector A
All you actually need is the dot product, however your vector A need to be normalized. Unity provides a well optimised method which projects a vector onto a given normal, even when it's not normalized: [Vector3.Project()][1].
All you need to do is subtract the projected vector B from the original vector B:
// C# / UnityScript
var vec = B - Vector3.Project(B,A);
If you want the new "vec" to have the same length as the old B you can do this afterwards of course:
vec = vec.normalized * B.magnitude;
***edit***
Since the question got already bumped i should add that Unity recently added a dedicated method for this kind of projection: [Vector3.ProjectOnPlane][2].
The method literaly is implemented the same way as my solution above, so it's just a bit simpler to use:
var vec = Vector3.ProjectOnPlane(B,A)
[1]: http://docs.unity3d.com/ScriptReference/Vector3.Project.html
[2]: https://docs.unity3d.com/ScriptReference/Vector3.ProjectOnPlane.htmlWed, 18 Jun 2014 21:15:02 GMTBunny83