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 /
This question was closed Jul 22, 2015 at 01:00 PM by meat5000 for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by Ewan Blackburn · Mar 12, 2013 at 04:38 PM · androidgpstabletunity android

GPS Application with Unity Android

Hi all, I've managed to create a tablet app that uses GPS to set the location of a camera object. I know the tablet is communicating with the unity application because it manages to receive the magnetic compass data and is being displayed as an integer on a GUI interface. My issue is that i cannot seem to get the GPS module to communicate with the unity android application i have made. All code i could find online seems to use outdated functions for unity 4.0 and i was wondering if unity android can even access the GPS module?

variables

 /* GPS Variables */
 var lat : float = 0;        //lattitude , longitude and altitude variables
 var lon : float = 0;
 var alt : float = 0;
 var accuracy : int =10;    //accuracy of the GPS module in m
 var distance : int = 10;    // minimum distance before next location variables allocation
 var maxWait : int = 20;    //maximum time (s) before time out
 var locationStatus : int =0;        
     

start function

 function Start () 
 {
     Input.location.Start();                    //enable location settings
     Input.compass.enabled = true;
     locationStatus = LocationServiceStatus.Stopped;
 
     startLocationService();                     //begin GPS transmittion
 }

 
 function Update () 
 {
    if(locationStatus == LocationServiceStatus.Running)
     {
         
         lat = Input.location.lastData.latitude;
         lon = Input.location.lastData.longitude;
         alt = Input.location.lastData.altitude;
         
         //print(lat);
         //print(lon);
         //print(alt);

 GUI.Box(Rect(Screen.width - 200,Screen.height - 50, 100,50), "Latitude => " +lat + "\n Longitude => " + lon + "\n Altitude => "  +alt );
        
     } 
 }
 
 
 function startLocationService()
 {
     Input.location.Start(accuracy, distance);
     
 
     while(Input.location.status == LocationServiceStatus.Initializing && maxWait > 0) 
     {
         WaitForSeconds(1);
         maxWait--;
        locationStatus = Input.location.status;
     }
 } 



The following code all compiles and runs on the android device but the lat lon and alt values stay as 0

Any suggestions would be great as I'm currently tearing my hair apart at this one!

Ewan

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

1 Reply

  • Sort: 
avatar image
1
Best Answer

Answer by imnimn · Sep 16, 2013 at 07:32 PM

Hi Ewan, the problem is that you use locationStatus of type int. And here is the problem I've tried to put Input.location.status instead of it and it is worked well . and changed after almost ten meters. also there is yield should be before wait for seconds

I wish that it be benefit to you and really thank you because it was benefit to me.

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

Follow this Question

Answers Answers and Comments

11 People are following this question.

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

Related Questions

Unity Android Inputs With Samsung Galaxy Ace 0 Answers

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Android Tablet GPS not working 0 Answers

How do I set my android app to landscape mode entirely? 1 Answer

Facebook unity sdk: is it possible to send friend invites/app requests to non app users ? 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