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 /
avatar image
0
Question by nicoolsen10 · Jul 03, 2019 at 07:24 PM · lineline drawinghexagon

How to draw a line around a hexagon

Hey so I'm creating a game with a hexagon map where you can build buildings but how do I make so there come a line around every single hexagon so I can see where I can build?

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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by LilGames · Jul 03, 2019 at 07:27 PM

GameObject -> 2D Object -> Tilemap

Set it to Hexagon type of map

Comment
Add comment · Show 3 · 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 nicoolsen10 · Jul 03, 2019 at 07:32 PM 0
Share

Okay, that helped but I wasn't clear I meant when I play the game there is a building mode how do I make so there comes a line around the hexagon?

avatar image LilGames nicoolsen10 · Jul 03, 2019 at 07:36 PM 0
Share

I would just draw a sprite or texture of an outline and use that centered to the tile center. (Not everything has to be done "through program$$anonymous$$g", if you know what I mean.)

avatar image nicoolsen10 LilGames · Jul 03, 2019 at 07:46 PM 0
Share

Yeah I know what you mean I just thought it would be easiest to make it so when you go into building mode it creates a line around the hexagon because you are not always in building mode

avatar image
0

Answer by Optrix · Jul 04, 2019 at 03:47 AM

If your world is FLAT, it's actually pretty easy.

Make a texture with a repeating grid of hexagons (you can probably find some tutorials on how to do it online, or even grab a pre-made one). Make sure the background is transparent. Ideally, the colour of the hexes should be white (if it's black, you can invert the colours).

Add a 3D 'Plane' to your scene and place it just above your ground plane.

Create a new material for the plane, and use the texture you created earlier, making sure it's transparent. I usually use one of the Alpha Blended particle shaders for this rather than the standard shader.

Assign the material to your plane, and then you're ready to go. You can adjust the tiling of the texture until it matches the size of your game tiles. If your texture was white, you can adjust the colour in the material, which is handy (it's easy to make it green, red etc.).

The joy of this is that you get a huge number of hexes for just two triangles.

If you want to then light up a single hex, you use a much smaller plane that is exactly one hex grid across and has a texture with just the single hex.

If your world is not flat, that's a different thing all-together. I'd be very tempted to do it with a custom shader in that case.

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

107 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 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

Vectrosity Line, how to draw centered, left or right of the path ? 1 Answer

How can I display flat image on cube gameObject 0 Answers

How to make dotted line for Bubble game? 1 Answer

What's the best way to draw a 2D line WITHOUT using LineRenderer? 1 Answer

LineRenderer Lines Have Inconsistent Widths 2 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