Find the closest treasure
Hey, I'm trying to create a 'Pokemon Go' like app. The goal is to find the closest treasure, the app should give where to go, ex: 38m North, 8m East. On every phone, the treasure need to be at the same position, i create an algorithm that said if the coord have a treasure or not return (EndWith(X%2.2839f*(Y/Modifier * 2784.3f) % 282.234492f / 4, 3, 2)); My problem is; it's very hard for the phone to find which is the closest treasure. I've create an example just for let you know what is my goal.
if(LastPosX != MapXPos || LastPosY != MapYPos) {
for(int s = 0; s < 10; s++) {
for(float x = MapXPos - i; x < MapXPos + i; i+=0.01f) {
for(float y = MapYPos - i; y < MapYPos + i; i+=0.01f) {
if(CoordIsDefine(x*100,y*100,1)) {
closetTreasurePoint = new Vector2(x,y);
IsBreak = true;
}
if(IsBreak) {
break;
}
}
if(IsBreak) {
break;
}
}
if(IsBreak) {
break;
}
i++;
}
}
This is very slow and it doesn't realy find the closet one...
Your answer
Follow this Question
Related Questions
Input.location.isEnabledByUser is always false, while developing on Win7 1 Answer
Location check for mobile app/game 0 Answers
Set different start positions for my player 1 Answer
How can I create movement like a bull? (Enemy run towards player) 0 Answers
how to setan animator&rigidbody after instantiation in my code 0 Answers