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 MithrilMan · Nov 11, 2014 at 10:11 PM · terrain3dtiled

generating a 3D terrain from a 2D tiled map

hi everybody, I'm pretty new with Unity but experted in C# language I'm trying to port a map that i've used in one game i made in XNA, that's a 2D top down map

look at this screenshot as an example (consider just the map) to understand how it's done actually Imgur

what I'de like to do, is use the map (that actually is composed by 3 files, 1 per layer, that specify witch tile to draw), plus a layer that gives the walkable tiles (1=walkable, 0 = non walkable)

actually the game is turn based and players are just jumping from a tile to the other.

The map is 502x502

I'd like to reproduce this, using the terrain in unity, but with some changes (maybe allowing player to move smoothly from a tile to the other, always honoring the walkable/non walkable

ok let me start questioning:

how can i generate a basic map from my files, as a base to work on its detail after it has been generated? I'd like to create a script that load my files in unity (using a menu) and load a starting point to work on, to prevent generating all from scratch

(i could change easily my files in order to just write if the tile is sand, grass, cliff, etc...) what would be the best approach to implement this?

I'd like to know how to create an empty terrain of 502x502 of size, and adding to it, as a first step a terrain which the height change based on the tile type (e.g cliff = 10, grass=2, sand = 1, road = 0, etc..) and smothing the edges if possible (but i can do this by hand)

then as a second step, i'll look at another file to place objects (trees, random flower/bushes on green tiles, etc...)

then as a 3rd step i should add something, to store that a specific tile (so a 1x1 area of the terrain) isn't walkable, so i guess i should add a box collider, placed at my x,y coordinate and with height from 0 to an high enough value? or to prevent an A* alghoritm to pass in a particular part of the map i've to use something different?

sorry if i've been a bit muddler on my request, recapping anyway the most important thing atm is to generate the basic map from my 2d tiled map easily without having to create it by scratch/hand, so i can then fine tuning it by hand in unity

thanks

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

Answer by bugmagnet · Nov 13, 2014 at 06:49 PM

The approach of trying to make a terrain to match a tile map is very unconventional.

If your goal is to get a 2D map to appear in 3D, might I suggest using Tiled to Unity?

Full disclosure: I wrote Tiled to Unity.

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
avatar image
0

Answer by Jeff-Kesselman · Nov 11, 2014 at 10:12 PM

Unity3D really is not a tile engine. Its an image and 2D physics engine.

You can do a tile map, but its a lot of work. You will have to write your own loader and you will get the best performance if you assemble the entire map into a single texture at run-time.

The other option is to create a flat mesh at runtime of quads (made up of two triangles a piece) with UV coordinates of each tile in the set set for each quad.

Again, its a lot of work however you go and rendering individual quads will be much more expensive in terms of frame rate (though it will save you memory.)

you could map each tile to a terrain height if you want... but i doubt the results will be very sensible.

To do that look at Terrain.terrainData

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 MithrilMan · Nov 11, 2014 at 10:30 PM 0
Share

thanks for your input but maybe i didn't explained me right. I didn't want to create a tiled map from my files, but just create a basic 3D terrain that i can fine tuning within Unity with its terrain manager, painting it with textures, etc... So ins$$anonymous$$d of creating that from scratch, generating the basic landscape from my tiles files would be handy

I'm not worried by the work to do, at the end i consider this a learning practice, i just would like to know who to create a terrain "block per block" according to my 2d map

Terrain.terrainData is the right direction, the problem is that i didn't found an indepth documentation about what i need

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

How to divide my terrain into selectable squares? 1 Answer

Terrain changes texture from certain distance! 0 Answers

how to manually make a voxel terrain? 1 Answer

Unity terrain grass is not working properly 1 Answer

Trees appear in ground when placed 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