Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
1
Question by Pedro Garcia-Huidobro · Nov 30, 2015 at 03:48 PM · coordinatesgps

How do I make LocationService.Start work?

HI, I been looking in the forums post like "How to get GPS coordinates in unity 3d" and they all link to the documentation "http://docs.unity3d.com/ScriptReference/LocationService.Start.html", but I can't make it work :c

The example screen is:

 function Start () {
         // First, check if user has location service enabled
         if (!Input.location.isEnabledByUser)
             return;
         // Start service before querying location
         Input.location.Start ();
         // Wait until service initializes
         var maxWait : int = 20;
         while (Input.location.status
                == LocationServiceStatus.Initializing && maxWait > 0) {
             yield WaitForSeconds (1);
             maxWait--;
         }
         // Service didn't initialize in 20 seconds
         if (maxWait < 1) {
             print ("Timed out");
             return;
         }
         // Connection has failed
         if (Input.location.status == LocationServiceStatus.Failed) {
             print ("Unable to determine device location");
             return;
         }
         // Access granted and location value could be retrieved
         else {
             print ("Location: " + Input.location.lastData.latitude + " " +
                    Input.location.lastData.longitude + " " +
                    Input.location.lastData.altitude + " " +
                    Input.location.lastData.horizontalAccuracy + " " +
                    Input.location.lastData.timestamp);
         }
         // Stop service if there is no need to query location updates continuously
         Input.location.Stop ();
     }

The error alt text If some body know how to get get GPS coordinates, it would be really appreciated Thanks in advance : )

screenshot-2015-11-30-105546.png (206.9 kB)
Comment
Add comment
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

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by meat5000 · Nov 30, 2015 at 03:48 PM

You need to put some info in to the start method.

 Input.location.Start (1,0.1);


Use these to check if its enabled by the user in Hardware and its status.

Also, I think you are mixing C# and JS in your script.

Use:

 #pragma strict
 import UnityEngine;
 import System.Collections;
 
 public class GPS extends MonoBehaviour
 {

Comment
Add comment · Show 3 · Share
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 Pedro Garcia-Huidobro · Dec 02, 2015 at 04:44 PM 0
Share

alt text

Didn't work :c

screenshot-2015-12-02-134359.png (189.8 kB)
avatar image Pedro Garcia-Huidobro · Dec 02, 2015 at 06:01 PM 0
Share

Thanks four taking the time to help me

I fix what a thing was the problem ( i was working on C# and apparently ir was a Java script ) Now In not sure if its working, but at least is working more than before XD The scene is playable, but the GPS coordinates are nowhere to be found

avatar image meat5000 ♦ Pedro Garcia-Huidobro · Dec 02, 2015 at 06:12 PM 1
Share

You may need to output them to a GUI, like OnGUI.

You can output them to the console just to see if its working.

Note that the examples in the Docs can be changed between C# and JS by clicking near the upper right corner.

The code I added my my answer is for the JS version

avatar image
1

Answer by DVFrance · Aug 17, 2016 at 02:18 PM

Hi, is there any solution to test GPS coordinate without building. I think it's a lost of time needing building to know if the code works or not ? I'm working on a mac with location services enable and unity editor console still saying Input.location.isEnabledByUser is false...

Comment
Add comment · Share
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

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

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

GPS coordinates (lat/long/altitude) to Unity 3D coordinates (x, y, z) 1 Answer

how to convert gps coordinates to unity 2 Answers

GPS doesn't work in AGPS mode 0 Answers

Are there examples of GPS-based indoor item placement apps? 0 Answers

How can i get gps signal on my andriod without data or wifi 0 Answers


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