Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm working on a birds-eye-view for our Unity3D game world, where each point of interest has a label hovering above it. The problem is that sometimes they overlap, although there is more than enough space on the screen for them to co-exist.

Can anybody think of a better way to separate them than checking every texture with every other texture and moving them away from each other?

share|improve this question

1 Answer 1

up vote 3 down vote accepted

I managed to do it this way:

  • Put all gui elements in a list.
  • sort them from bottom to top on their Y coordinate
  • loop through them in this order, if one collides with a previous one, move it up as much as necessary and go to the next.

this way you'll get a neat stack of GUI-labels (names of game objects in my case) and they'll never overlap.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.