- Home /
Unity Android Inputs With Samsung Galaxy Ace
Hi,
Im working with Unity android pro to create an augmented reality system that uses the compass, GPS and accelerometer to manipulate the location of a camera in 3D space.
To est this system im using the unity android remote ( i know this works because the game view is visible on the tablet and i can interact with GUI interfaces)
My issue is that after attaching a script to change the camera angle in the y axis in relation to the compass value all that happens is the compass magnetic heading says its '0' and does not change.
Is there an issue with my code (below) or is there an issue with unity compatibility accessing my input sensor values?
In the code I currently have all GPS code commented out
#pragma strict
var Yofset : float = 0;
var XrotOfset : float = 0;
var xaxis : float = 0;
var yaxis : float = Yofset + 0;
var zaxis : float = 0;
var anglex : float =XrotOfset + 0;
var angley : float = 0;
var anglez : float = 0;
var compassHeading : float ;
var lat : float = 0;
var lon : float = 0;
var alt : float = 0;
var accuracy : int =10;
var distance : int = 10;
var maxWait : int = 20;
var locationStatus : int =0;
function Start ()
{
Input.location.Start();
Input.compass.enabled = true;
//locationStatus = LocationServiceStatus.Stopped;
//startLocationService();
}
function Update ()
{
compassHeading = Input.compass.trueHeading;
Camera.main.transform.position= Vector3( xaxis, yaxis, zaxis);
Camera.main.transform.eulerAngles = Vector3(anglex, compassHeading, anglez);
/* 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);
} */
}
/*function startLocationService()
{
Input.location.Start(accuracy, distance);
while(Input.location.status == LocationServiceStatus.Initializing && maxWait > 0)
{
WaitForSeconds(1);
maxWait--;
locationStatus = Input.location.status;
}
} */
Cheers in advance
Try moving a magnet around the device. Are you sure this is supposed to work in Remote, have you tried running it just on the tablet?
cheers dave that worked! just a shame i cant use the remote and have to build to device every time i get a piece of code to actually compile!
Your answer
Follow this Question
Related Questions
GPS Application with Unity Android 1 Answer
compass in unity3d 3.2 4 Answers
Android Tablet GPS not working 0 Answers
Is there no simple way to get a device heading in Android with Unity? 2 Answers
GPS doesn't work in AGPS mode 0 Answers