- Home /
The question is answered, right answer was accepted
How to position UI elements on the Minimap's rectangle relative to the elements target position?
Hello everyone,
I'm making a minimap at the moment and recently ran into one issue. My minimap is similar to the RTS style minimap. I'm trying to position my UI elements on the minimap's rectangle relative to the world position of the element's target object. I know the size of the map as well as the size of the minimap's rectangle. Also when I register the element I send the owner (GameObject) means that I also know the position of the target object.
For example (On register, known info):
Map size: x - 150m, 125m
Minimap size: width - 225 pixels, Height - 250 pixels
Target Position: x - -25m, y - 0.5m, z - 35m
Element Position: ?
I tried to calculate the position like this:
x - (minimap.Width / mapSize.x) x target.localPosition.x
y - (minimap.Height / mapSize.y) x target.localPosition.z
But it looks a bit off for some reason..
What am I doing wrong with this?
Thank you.
Answer by Rukas90 · Oct 15, 2018 at 03:45 PM
Nevermind I was sending elements to be registrated before actually calculated the minimap's rectangle's size.
Follow this Question
Related Questions
ViewportToWorldPoint returns same value regardless of input 1 Answer
World position to graph position 2 Answers
LOCATION IN SPACE 0 Answers