- Home /
how to Break a vector3 line into half and Quater
Hi guys i am trying to break a Vector 3 line into Chunks to know the vector3 point on each of 25%, 50%, 75% of a line i managed to half(50%) of that line by adding Point A and Point B and then Dividing it by 2 but thats all i can achieve i am not able to do this kind of calculation for 25 and 75 % of the line
Here is my code
Vector3 centerposition(Vector3 h0, Vector3 h1 )
{
Vector3 centerPositionOFdis = new Vector3(h0.x + h1.x, h0.y + h1.y + 0.5f, h0.z + h1.z);
return centerPositionOFdis / 2;
}
Plz take a look and kindly Help me in Extracting those vector3 points on 25 % of a line and 75% of a line Thanks
,
Answer by HarshadK · May 04, 2016 at 07:37 AM
The answer (by SalvadorLimones) in this forum thread is what you want: Find a point on a "line" between two Vector3
You can click the share button under the Answer itself to generate a #link straight to that answer.
Didn't realize that. Thanks man! Added the link to the answer.
Thanks $$anonymous$$ate It works like a Charm I have been searching for this for 2 hours Thanks
Answer by aditya · May 04, 2016 at 07:46 AM
Vector3.Lerp is what you are looking for ... i've changed your centerposition
method to show how it works ...
Vector3 centerposition(Vector3 h0, Vector3 h1 )
{
Vector3 centerPositionOFdis = Vector3.Lerp(h0, h1, 0.5f);
return centerPositionOFdis;
}