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 gotys · Jan 15, 2014 at 08:09 AM · gridhexcreate a texturelight cookie

Hexagonal Grids

I am trying to build a strategy game based on hexagonal maps. Most hexagonal grids I found are based on the logic of tiling and instantiating single-hex-prefabs into a pattern to form the hexagonal gameboard. This seems to me like a waste of resources ? 20x20 grid would give me 400 GameObjects, which I think is silly ?

Another way people mention would be to use light cookie projectors. How would I go about dynamically coloring individual tiles when I want to show a path, or border ? I'd have to render the cookie texture procedurally ? Is this difficult + slow ?

And the final idea I found would be to procedurally create hex-planes ( let's say 20x20 ) and then stich the planes together to form a large map. 20x20 would be one single mesh - seems to me like a really optimized draw-call method. But I am totally confused about texturing individual hexes in such a mesh ? How would I dynamically change colors of a single hex , or hide/show individual hexes in such a single mesh ?

So my question is: Are there more methods that I don't know about ? What would be the most efficient - most mobile-friendly way of creating a hexagonal grid ?

Comment
Add comment · Show 2
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 Jamora · Jan 15, 2014 at 02:31 PM 0
Share

A 20x20 grid does equal 400 tiles, but it does not (necessarily) equal 400 draw calls. The amount of draw calls is deter$$anonymous$$ed by how many materials are used. If you have a texture atlas which contains all textures for all tiles, you can get a 400-tile grid for 1 draw call. $$anonymous$$anipulating individual tiles is also easy, because they are all individual objects.

Have a look at these links:

Unity: Optimizing graphics performance Unity: Practical Guide to Optimization for $$anonymous$$obiles

avatar image gotys · Jan 16, 2014 at 07:04 AM 0
Share

So, what would be a benefit of rendering 20x20 into ONE mesh versus the way you describe it - just have individual gameObjects grouped into one parent ? Or would there be one at all ?

2 Replies

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

Answer by nesis · Jan 15, 2014 at 02:06 PM

If you're worried about memory overhead, you can just create a script that handles an array of particles that will render directly without much overhead at all. This will still give you control over material too.

For even more memory efficiency, instead of swapping materials to change a hexagon's look, you could make a texture atlas and pack it with the different hexagons as needed. So instead of changing material, you just change the given hexagon particle's UV coords.

Comment
Add comment · Show 2 · 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 gotys · Jan 15, 2014 at 02:18 PM 0
Share

Can I change hexagon's UV coordinates when the hexagon is a part of one big mesh ?

avatar image nesis · Jan 15, 2014 at 03:07 PM 0
Share

Yep, you just need to change the UVs of the vertices in question. As far as I know, a mesh's UV array is mapped one-to-one with its vertex array (rather than mapping one-to-one with the triangles array), so to avoid affecting surrounding hexagons, you'd need to generate 6 vertices per hexagon, rather than sharing them across touching hexagons.

Anyone with more knowledge on this aspect feel free to jump in...

avatar image
0

Answer by Nick4 · Jan 15, 2014 at 10:55 AM

I'd go with line renderer.

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 gotys · Jan 15, 2014 at 02:19 PM 0
Share

Not a good choice, how would you flood-fill the hexagon with a color ?

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

22 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

Related Questions

Hex grid Help, Move from Cartesian coordiantes to slanting one axis along the hex diagonal 0 Answers

Modular hexagon terrain 0 Answers

Creating Hex Grids from Mesh Vertexes 0 Answers

How do I display my hex grid to the player? 0 Answers

Resize hex grid,Need to resize hex grid 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