Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by wenhua · Feb 01, 2012 at 07:35 AM · distance

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

alt text" />

        //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);

Comment
Add comment · Show 4
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image syclamoth · Feb 01, 2012 at 07:49 AM 3
Share

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.

avatar image wenhua · Feb 01, 2012 at 07:53 AM 0
Share

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.

avatar image syclamoth · Feb 01, 2012 at 08:04 AM 2
Share

You need to start understanding things, rather than just copying code off the internet.

avatar image wenhua · Feb 01, 2012 at 08:11 AM 0
Share

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

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

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


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges