Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 11 Next capture
2021 2022 2023
1 capture
11 Jun 22 - 11 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
1
Question by adriandevera · Jul 10, 2015 at 05:34 PM · mesh3dproceduraltileadjacent

Procedurally Connected Mesh/3d Model Tiles?

On a grid-based game, how would I procedurally determine adjacent objects (North, South,East, West) in an efficient manner?

I already have everything implemented from grid, to grid object placement, to actual object placement. Id like to implement this automatic system rather than having the player ie. select a corner for the building or sidewalk model

Below is a picture to better describe what Im trying to explain:

alt text

I have several 3d model variations of multiple objects from cliffs to paths/fences to buildings. Im aiming to allow players to place an object in runtime where if another of the same object is placed next to it, then depending on the direction a different mesh piece would replace the other.

Think of it as the Cliff system while making a map in starcraft 2 or warcraft 3.

alt text

(Place an object, in this case a cliff, then place another next to it and both will change where the left cliff would have no face on its right side and the right cliff would have nothing on its left face.)

Im trying to do this because allowing objects to simply overlap with one model rather than having multiple variations of the model with different faces not rendered is more ideal. Another example with exactly what I want: alt text

(Web browser Version)

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

1 Reply

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

Answer by Cherno · Jul 10, 2015 at 05:46 PM

You have to implement your own tile identification logic. Each tile needs something that identifies it's basic type, such as "hill", "river", "road" and so on. This can be done in several ways, for example a simple int where 0 is clear, 1 is ground, 2 is road, 3 is hill and so on. Or a string that directly describes the type. Or a enum value. Something like that.

Then, when building the mesh, you have to go through each tile, and for each tile, check it's neighboring tiles for their type as well. Based on that information, your code can decide which mesh part to use for the current tile. For example, if the tile at x,y is a hill, and the tile at x+1,y (left neighbor) is ground/clear, then you need a cliff for the tile at x,y. It gets more complicated the more neighbors you have to take into account, of course.

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 adriandevera · Jul 10, 2015 at 05:53 PM 0
Share

Ah okay perfect. I made a rough draft of my own version last week doing exactly what you explained. It works properly and as intended but now a question of what is an efficient way? Ive known people use something like raycasts (which is fine if I place one object at a time and call the method) but this may be an issue if I do a mass placement?

The best way would be to locally check that tile rather than the whole tile map which is what you explained, so now would I use Raycasting (can be costly), forloops (what Im currently using) or do you have another suggestion?

Thanks for the quick and awesome reply by the way!

avatar image Cherno · Jul 10, 2015 at 06:18 PM 0
Share

Raycasting is highly inefficient for this. Take a look a $$anonymous$$inecraft-in-Unity tutorials and how they create the terrain mesh. You declare a two- or three-dimensional array where each element corresponds to one cell of your world. I assume you already do this since you mentioned using loops, which is exactly how you should do it.

avatar image adriandevera · Jul 10, 2015 at 07:31 PM 0
Share

Ah alright, then I suppose the system I have is already as efficient as it is.

Thanks for the advice again!

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

23 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

Related Questions

Determining where a mesh triangle faces 1 Answer

How to texture walls in procedurally generated mesh? 1 Answer

Convex Mesh Collider on Procedurally generated mesh does not conform.. 2 Answers

One vertex array per submesh 2 Answers

Mesh-Cutting metal Jaws-of-life 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