GPS First Person Scale. But can't walk we add a function that the camera will move after the long&lat compute. But it doesn't work.
We add function that every update of the long/lat will call the function and start computing for new x and z of the object
double multLon, distLat , multLat, distLon; double prevLat = 0; double newLat; private const double zpos = -567; float latToz (double lat){ newLat = lat; //lat = (lat - 53.178469) / 0.00001 * 0.12179047095976932582726898256213; if (lat != 0) { if (prevLat != 0) { multLat= (newLat - prevLat); distLat = zpos - multLat; /lat = lat - 580.5644; z = lat - 2;/ } else { /lat = -561.9; z = lat;/ distLat = zpos; } } else { distLat = zpos; } prevLat = lat; return (float)distLat; }
double prevLon = 0;
double newLon;
private const double xpos = 496;
float lonTox (double lon){ // 120.9767 // 120.9774 // 120.97611
newLon = lon; // newLon = 120.9767 // newLon = 120.9774 // newLon = 120.97611
if (lon != 0) { // true // true // true
if (prevLon != 0) { // false // true // true
multLon = (newLon - prevLon);
distLon = xpos - multLon; // dist = 375.7223
} else {
distLon = xpos; // dist = 375.0223
}
} else {
//Debug.Log ("Kindly open the GPS/Location");
distLon = xpos;
}
prevLon = lon; // prevLon = 120.9767 // prevLon = 120.9774
return (float) distLon; // 375.0223 // 375.7223
}
float bagongX = 0f;
float bagongZ = 0f;
//double temp = 120.9767;
//int timer = 0;
//private System.Random rand;
void Update(){
if(state == LocationState.Enabled){
float deltaDistance = Harvesine (ref latitude, ref longitude) * 1000f;
if(deltaDistance > 0f){
distance += deltaDistance;
coins = (int)(distance / 100f);
}
}
//rand = new System.Random ();
//if((timer%=50) == 0) {
//temp += rand.NextDouble() + 0.05;
//longitude += (float)(new System.Random ().NextDouble() + 0.05);
//temp += new System.Random ().NextDouble() + 0.05; // 0 - 0.05
bagongX = lonTox(longitude);
bagongZ = latToz (latitude);
// print (bagongX);
//}
///
///timer++;
this.transform.position = new Vector3 (bagongX, 463, bagongZ);
}
Your answer
Follow this Question
Related Questions
How can I prevent my player from flying when i use the space bar? 0 Answers
Need my fish character to move up and down, not just left and right. 0 Answers
How to start an animation in script? 2 Answers
How to make changing direction in my FPS game less jerky? 3 Answers
infamous first light run code help 1 Answer