• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
This question was closed Oct 15, 2018 at 03:46 PM by Rukas90 for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by Rukas90 · Oct 15, 2018 at 03:21 PM · positioningworldspaceminimaprectangleelements

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.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

  • Sort: 
avatar image
0

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.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

90 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Select object through Mini Map in world Space 1 Answer

How to create a worldspace rectangle(region) 1 Answer

ViewportToWorldPoint returns same value regardless of input 1 Answer

World position to graph position 2 Answers

LOCATION IN SPACE 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges