Im working on a line chopping function, in certain cases I want to call this function because i sometimes need to slightly extend a line so that it will register with the intersection of other lines and my script will work. The below does nothing, im still working on it but when i mess with either newLine or even bugLine it messes with my whole game!
static public LineSegment ExtendLine(LineSegment line, float dist)
{
LineSegment newLine = line;
LineSegment bugLine = newLine;
// Debug.DrawLine(bugLine.points[0] - Vector3.up, bugLine.points[1] - Vector3.up, Color.green, 20000, true);
Vector3 bb = bugLine.points[0] - bugLine.points[1];
bb = bb.normalized;
float mag = bugLine.points[0].magnitude - bugLine.points[1].magnitude;
Vector3 first, second;
first = bugLine.points[0] + (bb * 0.1f);
second = bugLine.points[1] - ( bb * 0.1f);
//Debug.DrawLine(first - Vector3.up, second - Vector3.up, Color.green, 20000, true);
//bugLine.points[0] = first;
//bugLine.points[1] = second;
return newLine;
}
the above doesn’t change anything but it also doesnt return an extended line
[CODE]
static public LineSegment ExtendLine(LineSegment line, float dist)
{
LineSegment newLine = line;
LineSegment bugLine = newLine;
// Debug.DrawLine(bugLine.points[0] - Vector3.up, bugLine.points[1] - Vector3.up, Color.green, 20000, true);
Vector3 bb = bugLine.points[0] - bugLine.points[1];
bb = bb.normalized;
float mag = bugLine.points[0].magnitude - bugLine.points[1].magnitude;
Vector3 first, second;
first = bugLine.points[0] + (bb * 0.1f);
second = bugLine.points[1] - ( bb * 0.1f);
//Debug.DrawLine(first - Vector3.up, second - Vector3.up, Color.green, 20000, true);
bugLine.points[0] = first;
bugLine.points[1] = second;
return newLine;
}
the above messes with the stuff outside of the function, which makes no sense!!!
any ideas?? thanks