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 iilleen_unused · Jun 09, 2013 at 03:23 PM · gameobjectterrainintersectionhex

Position of game objects on a hexagonal grid

Greetings, In my project I'm using a normal terrain and a hexagonal map, which is represented by a 2D bool array. I also have an algorithm which converts world position to hex number.

I want to loop for all the scene objects and check if they intersect with the terrain, and over which hexes - to determine if character can move there or not. It's not a problem for objects with small diameter like a palm, which will most likely occupy one hex, but with bigger objects like rocks, buildings, walls etc it gets problematic.

alt text

Pic related, it's the terrain with hexagonal texture (size of the actual hexagonal map) projected on it.

If any additional data is needed I will provide it. Thanks in advance

Comment
Add comment · Show 1
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 erfan · Jul 03, 2014 at 11:02 AM 0
Share

@iilleen_unused I have a project that I must create a Hex map like your map !! Exactly I want to know How you create Hex map On the terrain like that?

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by xandermacleod · Jun 09, 2013 at 03:43 PM

I don't have the code on me, but I suspect you may need to provide information regarding your terrain's height (in Terrain>SetResolution). The way I would do it (with admittedly little unity knowledge) is to work out where the object's vector3 position from the corner of the terrain, and then compare it's Y-position to the heightmap's value/the setresolution height.

That will only tell you if the object is above or below the terrain though, not whether it intersects. You might require some collider checks for that. You should also be able to cast a ray either up or down from the object and use the hit-info for making a comparison that should work with your algorithm (provided you don't have multiple stacking objects ontop of each other).

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 iilleen_unused · Jun 09, 2013 at 05:17 PM 0
Share

but this will only tell me if the centre of the object is intersecting the terrain, not over which hexes the object is (if it's bigger than one hex)

avatar image
0

Answer by JoshV · Oct 31, 2013 at 05:10 AM

Cheat, and pretend each hex is a sphere or cylinder or capsule? Then you could do something like Physics.Capsule() at the hex's position and given a radius that would fit inside the hex.

(And I would try to do this on startup for objects that aren't going to move)

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

19 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

Related Questions

Making changes to a terrian in game 1 Answer

Vegetation problem 1 Answer

attach Hexagonal Grids to a terrain like a texture 0 Answers

Airplane - Collision With Terrain Problem 1 Answer

Game Object - world space to grid coordinates 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