I’m quite new to Unity and would like to explain my approach (so far) a bit more accurately.
This is a top down style game that I’m using “Tiled” from MapEditor(.org) for art. After importing my map w/ Tiled2Unity, I have gotten a ‘Player’ with functional animations, basic collisions, and movement (using AddForce, I’m quite enjoying the ‘floatiness’)
My map is built of 6 layers each with their own mesh (tree tops, tree trunks, bridges, water, ground, plots(farming))
I’m here looking for guidance on how to interact with a certain mesh, as well as detect each square within that mesh to avoid the overlapping of tiles used.
Like using a ‘hoe’ on a single tile within the designated area of farming land, to then create a ‘tilled’ tile, that accepts seeds
How should I approach this fundamental chain of ideas? My brain is missing some strings to tie it all together…
Edit
I suppose the best reference is old style “Harvest Moon: Friends of Mineral Town”
http://www.freeroms.com/roms_screenshot2/gba_harvest_moon_-_more_friends_of_mineral_town_2.jpg
Thanks,
DigitehK
The solution is easy and not at the same time. I cannot speak for Tiled2Unity or how they created their maps, because I haven’t used their system. However, our homemade tile engine Paperworlds uses a mesh based tile system that allows “detail” tiles to be placed onto the base tiles, so I imagine this information will still be relevant.
So when I say base tile, that is any tile that has no transparency and is a literal square tile such as your tilled tile. Now you want to sprinkle seeds on it, which is a tile that has transparency in it, while still showing the base tile underneath. I call those detail tiles. I am not sure how much you know about how your current system works, but essentially you should have an array of tile ids for your base tiles in map data. You will need to add a similar array that holds the detail tiles, how creative you get with it is based on your imagination. You could in theory setup a system that allows an unlimited number of detail tiles to be stacked onto the same base tile (although that may be unnecessary).
Next, you will need procedural mesh generation if you don’t already have it. This basically means that your meshes can be re-generated at runtime because tile data has changed. So when you sprinkle the seeds, you set the ID of X / Y in your detail array to something other than 0 (we usually use 0 as a “nothing there” tile). Setting new tile data should be setup to inform your mesh generator that the corresponding chunk needs a new mesh. Then in your mesh generation code, when it loops through the base tiles, have it also check detail tiles at the same time. If detail tile id > 0, generate vertices in front of base tile on the Z axis, along with corresponding tris and uvs. In Paperworlds detail tiles are -1, -2, -3, etc. on the Z axis, while base tiles are 0, and walls (behind the base tiles) are 1.
It is a bit complicated and technical, but I hope that made sense haha. Good luck to you!
1 Like