Payedimaunt
Payedimaunt

Reputation: 1070

How to find a point X between two Vector3 in Unity3d

OK, it's not easy explain me so i will use an image.

I have the following problem :

I have a line between two points A and B. I need to calculate the coordinates of the 'X' point knowing that it is perpendicular to the point C.

Editor situation

Upvotes: 2

Views: 2349

Answers (1)

Hellium
Hellium

Reputation: 7346

Unity has a built-in function for this : Vector3.Project

Vector3 AB = B - A ;
Vector3 AC = C - A ;
Vector3 AX = Vector3.Project(AC, AB);
Vector3 X = AX + A ; //How say Lutzl works!

Upvotes: 4

Related Questions