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 jakerman999 · Jan 09, 2011 at 05:35 AM · textureruntimegridhexagoncell

determine neighboring cells on a hex grid.

I'm generating a hex grid on initialization, where a cell is given a different texture based on it's position. A cell is a plane with a hex texture that has transparent cutoffs. Cells with different textures are different prefabs, created with the Instantiate function.

This worked fine for creating a grid, but now I need each cell to know which texture(or which prefab) the closest cells are. For example, the "J" key on a standard qwerty keyboard would have to know that it is surrounded by H, U, I, K, M, and N, plus the directions those keyes are in. My current ideas are to pass a variable to script of each cell through instantiate(is this possible?) or to determine what texture is displayed at a set of coordinates(I believe this can be done through a helper camera).

I could also re-do the system for creating the grid to either rename the prefab instances upon creation(is this possible?) or to create the grid with only one prefab that changes texture after instantiate based on a variable(or some other identifier).

I am also open to any other ideas I haven't thought due to unfamiliarity with unity.

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
1
Best Answer

Answer by Jesse Anders · Jan 09, 2011 at 03:20 PM

My current ideas are to pass a variable to script of each cell through instantiate(is this possible?)

You can't pass argument as such, but Instantiate() returns a reference to the newly instantiated object, through which you can make any needed modifications.

I could also re-do the system for creating the grid to either rename the prefab instances upon creation(is this possible?)

Yes (see above).

(I'm not sure if that entirely solves your problem, but if not, perhaps you could edit your post and clarify the question a bit.)

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 jakerman999 · Jan 09, 2011 at 04:00 PM 0
Share

I've since learned that Instantiate can return to a GameObject type variable, and I believe this is what you are suggesting. Is there anyway to assign the prefab to an array ins$$anonymous$$d of a single variable? Upon this, could Instantiate return to a multidimensional array?

avatar image Jesse Anders · Jan 09, 2011 at 06:16 PM 0
Share

You can assign the return value of Instantiate() to whatever you want (a single variable, an element in a 1-d array or multidimensional array, an element of some other type of container. etc.).

avatar image
0

Answer by M.Larin · Oct 09, 2013 at 10:17 AM

A sphere whith radius of your hexagon side, that casted from center of hexagon, will collide only whith closest planes.

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

1 Person is following this question.

avatar image

Related Questions

Highlighting tiles on a hexagonal grid 1 Answer

dynamic images for textures ar runtime 2 Answers

Draw Texture in a grid like Trainyard 2 Answers

Beginner Help: hex grid set up for battlefield 0 Answers

How do I import TGA, DDS, GIF, PCX and BMP files at runtime? 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