- Home /
Help in Calculate Point to Point distance
Base on the Map below,Anyone Has any idea how to find out the distance from point 1 to 2. and point2 to 3...Base on the script belwo. Below the Map is my script for Clicking the point1 onwards
" />
//mouseclick to add waypoints
if (Helicopter_Script.flightState == 0)
{
if (Input.GetMouseButtonDown(0))
{
position = Input.mousePosition;
if (position != prevMousePosition)
{
prevMousePosition = position;
//Debug.Log("MouseClicked: mousePosition (x) - "+position.x + ", (y) - "+position.y);
if ((position.x>=20 && position.x<=570) && (position.y>=150 && position.y<=780))
{
if (helicopter.GetComponent( "Helicopter_Script" ).wayPoints.length == 0)
GameObject.Find("Home").renderer.enabled = true;
if (helicopter.GetComponent( "Helicopter_Script" ).wayPoints.length < maxWaypoints)
{
points1.push(position);
linePoints = new Vector2 [points1.length + 1];
points1.ToBuiltin(Vector2).CopyTo(linePoints,0);
linePoints[linePoints.length-1] = points1[0];
if (line1 != null) Vector.DestroyLine(line1);
line1 = new VectorLine("Line1", linePoints , Color.red, null, 2.0, LineType.Continuous);
Vector.DrawLine(line1);
mapPosition.z = (position.y - 150) * (3300.656 + 1327.897) / (780 - 150) + (-1327.897);
mapPosition.x = (position.x - 20) * (824.0381 + 3285.686) / (570 - 20) + (-3285.686);
object = "p"+(helicopter.GetComponent( "Helicopter_Script" ).wayPoints.length+1);
GameObject.Find(object).transform.localPosition.x = mapPosition.x;
GameObject.Find(object).transform.localPosition.z = mapPosition.z;
GameObject.Find(object).renderer.enabled = true;
Helicopter_Script.wayPoints.Push(mapPosition);
Helicopter_Script.isNewWayPoint = true;
Debug.Log("numWaypont - "+Helicopter_Script.wayPoints.length +", mapPosition - "+mapPosition);
}
}
}
}
}
//draw lines to waypoints
// pathPoints[pathIndex] = thisTransform.position;
// pathLine.maxDrawIndex = pathIndex-1;
// Vector.DrawLine (pathLine);
// Vector.SetTextureScale (pathLine, 1.0);
Come on, didn't I answer this question yesterday? The answer is the same.
Vector3.Distance(firstPoint, secondPoint);
that is all you need for this.
o i put the map and a script to make a clearer understanding for reader for more ideas generate ^^yea in the main time, i am also trying to solve it,just post this to see if anyone know how my script work in case i cant solve it. as This script click to add waypoint,i have no idea how does it add waypoint.
You need to start understanding things, rather than just copying code off the internet.
sure bro, to tell you the true, i dont like program$$anonymous$$g, just this project i bad luck gets to do software, no choice but to start learning a new world T_T
Your answer
Follow this Question
Related Questions
enemy shoots with animation 1 Answer
change tiltshift distance with mousewheel 0 Answers
Maintain height/Altitude/distance from ground? 2 Answers
Animation / Distance 0 Answers
Why this script is not working? 1 Answer