- Home /
Vector3.Project() not working as expected?
Consider the following shitty image:
N is my normal, V is a point I am passing to Vector3.Project():
Vector3 P = Vector3.Project(V, N);
The problem is that the result of P is where I show in the image, but I expected it to be somewhere along N.
I have thrown in Debug.DrawRay statements to ensure my point and normal are as I expect, and they are. Am I misunderstanding what Vector3.Project() does?
Depending on the direction of N, the result of P is different (sometimes closer, sometimes worse), but it is always incorrect.
What could I be doing wrong?
EDIT:
If I do this (where Np is the world position of the normal vector I care about):
Vector3 P = Np + (N * Vector3.Distance(V, Np));
I get the desired result. So what is it that I am misunderstanding about Vector3.Project()? How would I use Vector3.Project() to get the same result as the above expression?
Is V a position aka the vector OV, where O is the origin of the world (in the game, not in a biblical meaning)?
You may want to try with the vector (V - origin of N)
Your answer
![](https://koobas.hobune.stream/wayback/20220612043934im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Rotate plane by normal, how to calculate new position? 1 Answer
How do you find the tangent from a given normal? 2 Answers
Average of Normals 1 Answer
Angle between Ray and Normal 1 Answer