When creating Munchy Bunny! I was using an extension called Tidy Tile Mapper which allows you to create levels using 3D tiles. This is a fantastic extension for Unity which offers a lot of powerful features. Unfortunately I encountered several major limitations which made it difficult to achieve what I needed:
- Each level consists of two separate grids; a large one for platforms and a smaller one for chocolate bricks, eggs, diamonds, etc. The grids have to occupy the same space on the Z-axis. This meant that the grids had to be separated to work on them and then moved back again afterwards. This was an extremely slow and tedious process which caused the Unity editor to crash on multiple occasions.
- I found that the Unity editor began to run extremely slowly when using grids (even when empty) of 300 columns by 100 rows (the small grid size for Munchy Bunny!)
- It was not possible to define custom block orientations which meant that I was unable to create blocks to the quality that I desired.
Tidy Tile Mapper has many fantastic features but from my experiences it does not perform well with large grids. Additionally it is far from ideal when working with multiple grid sizes that occupy the same space.
So I decided to create my own tile system that would make it easier for me to create what I need. For those interested the extension is available from the Unity Asset Store, and there is more information here.
Tile system grids are represented virtually using a grid Gizmo (as opposed to lots of empty game objects). This has several advantages:
- Less intensive on CPU and GPU in editor, thus allowing for larger grids. Obviously the editor will still slow down progressively as tiles are painted, but the absence of “empty” game objects made a massive difference for me!
- Painted tiles can be selected easily. The box selection tool in Unity was generally useless previously because it kept selecting the “empty” objects generated by Tidy Tile Mapper.
- Painted tiles can also be moved, rotated and scaled once painted, and components can be added and configured. Such manual tweaks will usually be preserved when tiles are refreshed!
I also found it useful to add options to allow the scale of painted tiles to be specified on a per-brush basis. This means that tiles can be scaled to match the grid upon being painted if necessary.
Tidy Tile Mapper offers the ability to automatically orientate tiles by specifying one or more prefab variations for each desired orientation. There were a fixed number of orientations that can be changed which may be fine for some developers, except I found myself needing more to achieve the smooth rounded edge effect that I was after. So with my tool I decided to make it possible to add any custom 3×3 orientations as needed. My tool can also attempt to determine the next-best orientation if the required one is undefined.
Additionally I was able to offer more control over the way in which painted tiles orientate against one another. There are a number of ways in which tiles can be coalesced (joined) which means that multiple brushes can be designed to work with one another.
Oriented brushes (like platforms, walls, etc) can become quite complex with quite a number of associated prefabs. This is fine until you want to create multiple variations of the same brush. For example, you may have a green grassy platform and a cave platform. So I implemented the ability to create alias brushes which makes it really easy to define new variations of existing brushes. Materials can be remapped and some properties can be overridden if needed.
I decided that it would be good to include some build functions. The purpose of these is to combine painted tiles (that are marked as static) into a single mesh. Vertices can be automatically snapped using the given threshold to avoid visual anomalies that can otherwise occur due to minor floating-point inaccuracies. Brushes can also be marked as “smooth” which causes their normals to be recalculated (again using the given threshold) which can help to smooth joins between painted tiles.
Take a look at the tile system in action in the Munchy Bunny! demo for the Google Chrome web browser. Players will notice an improvement in graphics in the iOS version in our next update!