Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
avatar image
0
Question by deltadiamond · Aug 10, 2012 at 08:39 PM · tilehexagon

how to implement hexagonal tiles?

I'm making a turn-based strategy game using hexagonal tiles, and I'm looking for an easy way to be able to move units and place tiles (without having to find the specific x and y values). Is there a way to do this?

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

3 Replies

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by ScroodgeM · Aug 10, 2012 at 08:41 PM

simply use field X*Y but skip all tiles that X+Y=even

now you get a something like checkmate tile placing. replace squares with hexagonals, a little scale in X axis and you got right hexagonal field 8)

alt text

  1. declare a size of field (any number depends on gameplay), for example, X*Y=10*10

  2. don't use in gameplay cells that are even or odd. use only odd or only even

  3. in odd cells, draw tiles

  4. write your gameplay 8)

may be not enough explained. tell if so.


1.png (31.9 kB)
Comment
Add comment · Show 8 · 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
avatar image deltadiamond · Aug 10, 2012 at 08:50 PM 0
Share

I'm pretty new to Unity, so what do you mean by "field X*Y"? And what exactly do you mean by "checkmate tile placing?"

avatar image ScroodgeM · Aug 10, 2012 at 09:21 PM 0
Share

check answer again

avatar image deltadiamond · Aug 10, 2012 at 09:26 PM 0
Share

Thanks a lot! One last thing: how do I check to see if the X and Y for each position add to make an even number?

avatar image ScroodgeM · Aug 10, 2012 at 09:43 PM 0
Share

for (int x = 0;...
{
    for(int y = 0;...
    {
        if ((x & 1) == (y & 1))
        {
            ...place a tile here
avatar image deltadiamond · Aug 11, 2012 at 12:01 AM 0
Share

what do you mean "x & 1" ? And if you are evaluating whether the x part is equal to the y part, then wouldn't that only create a tile on the main diagonal?

Show more comments
avatar image
0

Answer by zyzyx · Aug 11, 2012 at 11:42 AM

You may want to check out this blogpost: Hexagon of Hexagons

Comment
Add comment · Show 1 · 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
avatar image
0

Answer by deltadiamond · Aug 11, 2012 at 03:55 PM

Thank you! This was exactly what I was originally looking for. I now only have to figure out which method to use. Edit: I'm not too familiar with C#, so I don't know how to replicate that code.

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

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

9 People are following this question.

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

Related Questions

How to fix this null reference exception? 2 Answers

Hexagonal grid with 120 degree angles 1 Answer

An arrow pointing from one hexTile to another hexTile 0 Answers

Cannot assign the tile png to the tile asset file 0 Answers

Shadows on floor edge 0 Answers


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