Hello,
I am trying to detect if a Vector3 (P) is between other 4 Vectors3 (A, B, C, D)
I have tried to do this using two vectors in stead of 4 using this script:
function GetPositionBetweenTwoVectors (position : Vector3, VectorA : Vector3, VectorB : Vector3) : float {
var displacement : Vector3 = position - VectorA;
var currentSegment : Vector3 = VectorB - VectorA;
var fraction : float = Vector3.Dot (displacement, currentSegment) / currentSegment.sqrMagnitude;
return fraction;
}
But this crash when the Vector3 P is outside of A, B.
How can I determine this statement?
Thanks