Ok, so I’m writing some minimap code, and I’m having an issue. I’ve got the code to draw a dot on the map as long as the dot is close enough that it’s actually within the view of the minimap itself. What I’d like to do, though, is make it so that if you walk too far away from your objective, and it would fall off the edge of the minimap, that the dot instead just gets stuck at the edge of the circle and simply rotates around you to show you what direction to go to get to it. Here’s the code I’ve got so far for the dot when it’s close. Any ideas?
for (var ObjectiveHigh : GameObject in HighObjectives) {
//find location
var objPos = camera.WorldToScreenPoint(objective.transform.position);
//is the objective visible on the map?
//TODO OPTIMIZATION check on computational cost of Vector3.Distance. Square roots are usually expensive. Would Vector2 work (and be cheaper)?
dist = Vector3.Distance(objective.transform.position, playerTransform.position);
if (dist < 170){//this is roughly the size of the minimap
//draw icon
GUI.DrawTexture(Rect(objPos.x - 25,Screen.height - objPos.y - 25,50,50),objectiveIcon);
}
else if (dist > 170){
//This is the area I need help with
}
This question is nearly a year old ! =] The OP is looking for a way to show the placeDot on the minimap only to a certain range, then when past that range the placeDot stays on the outer limits of the minimap, without moving further away.
– AlucardJay