Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 Jun 22
sparklines
Close Help
  • 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 /
  • Help Room /
avatar image
0
Question by andrewjdavis · Nov 16, 2015 at 04:41 AM · 2dhex

Hex map graphical overlap issue in Unity2d

I've got a mostly functional procedurally generated hex map going in Unity2d. I'm getting down to the stages of refining things and trying to work out little kinks, and this one has me a bit stumped.

When I place my tiles, I iterate through a simple pair of for loops to call a tile placement function:

 for (int x = 0; x < width; x++) 
         {
             for (int y = 0; y < height; y++) 
             {
                 terrainGen.DrawTerrain(x,y,terrainType[x,y]);
             }
         }

Seems to mostly work, except that I'm having issues on specific parts of the rendered maps where some graphical elements that I want to overlap from one hex to the next are getting clipped (blue looks ok, red is clipped):

alt text

I'm pretty confused about it, even though I suspect it has something to do with the way I iterate through the tile placement, combined with the treatment of the odd and even rows, since I need to slightly alter their transform placement based on the row. Here is the coding I use to alter those row coordinates:

 // coordinate system corrections for hex placement
         if (y%2 != 0)
         {
             x = (120 * x) + 60;
             y = (106 * y);
         } 
         else if (y%2 == 0)
         {
             x = (120 * x);
             y = (106 * y);
         }

Anyone have a clue what would make it clip only on even-numbered rows or get clipped by the odd-numbered row, depending on how you look at it? The layering, sort order, etc. all seem to be the same (plus, they look fine on the next row down with the same tile). It also seems to only impact overlaps that should happen on the left/west side of the overlapping tile. Tiles in the same row that overlap on the right/east side seem to be fine.

EDIT: Credit to Kenney.nl for the graphic assets I'm using here (in slightly modified fashion, anyway).

overlaps.png (300.5 kB)
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

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

45 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

Related Questions

How blend an UI Image with the background? (Multiply Effect similar to Photoshop) 0 Answers

Load Scene Unity by Application.LoadLevelAsync 0 Answers

AddExplosionForce help? 0 Answers

Help Change Color of Object on Collide 1 Answer

Position changing though set position code running 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges