Which one is better for a platformer? What I mean by the second option is making entire chunks of levels in graphic editor with copypasting tecnique like ones used for drawing tile palettes and then import them as a whole. The goal is to make it easy to draw while not so boxy and less obviously copypasted. Now I’m weighting these two options and came up with a list of advantages and disadvantages I know and some questions.
Tilemaps
Built-in tools for drawing levels in engine with no need for differently working placeholders and additional efforts from the artist
Allows to assign Scriptable Object data to certain types of tiles, which eases creation of various gameplay effects
Restricted by tileset, therefore require more elements with good compability to avoid repetition
Require separate objects to hide unwanted tile massives beyond foreground
Are boxy and quite incompatible with natural shapes, could need monolyth sprites with collision anyway
Sprites
Can be drawn with more elaborate shapes and less copypaste where needed
Don’t require separate foreground sprites as this stuff can be drawn right on top of the boxy parts.
All work goes in a graphic editor, needs some way to measure in-game distances to transfer there
No tile data feature, more manual work for various surface interactions
Need some work in proper placing and setting colliders
Now about things I’m not sure in.
Performance.
Is a tilemap collider better or worse than a lot of box/polygon 2D colliders? How much heavier is a ton of separarte sprites compared to tilemap data and how critical this difference is? How do tilemaps handle occlusion culling? Is having multiple tilemaps for different areas a bad idea?
Animated and destructible tiles.
How hard it is to make, for example, a secretly destructible wall or a temporary dissolving plafrom with them compared to them being separate objects? Do I need to, or they would perform fine as workarounds with tilemap anyway?
Access to polygon’s sections.
How do I tell the object to tell the player things like which wall is climbable and what walking sound should be played on this floor? The only thing which seems to be useful in PolygonCollider2D class is a Vector2[ ] points property, but is there an way to mark and get references certain sections through it without excessive coding and setting properties during the scene load? Is spamming box/edge or any set of multiple colliders instead a bad idea? If I go with sprites and underlying tilemap without a renderer, how could I set differen types of tiles then?
Tilemap collider with Used by Composite and Composite Collider can be more efficient than many boxes/polygons.
A TilemapRenderer with chunk mode can be much more performant than SpriteRenderers. If it instead uses Individual mode, it is still more efficient but less dramatically. The magnitude of difference in both cases also depends. How many sprites are on screen?
With a good loading system, you might load in sections of your level so that you don’t have much out-of-view loaded in so there’s not much culling cost.
The best way to answer this would be to make a test where you populate a mock scene that’s representative for your game on a tilemap then iterate the cells of that tilemap and spawn a gameobject with SpriteRenderer in the same cell. Have a key to flip between the tilemap being enabled vs. all the SpriteRenderers. Compare in the Profiler.
Tilemap culling isn’t publicly known. I doubt it does anything for occlusion. If you want to see a very advanced system, lookup on YouTube “Ori And The Will of the Wisps Switch Analysis: Inside An ‘Impossible’ Port.” This also illustrates my previous point about a good load system.
It’s fine; it’s common practice.
But you should not think in terms of EITHER / OR. Tilemaps are almost always combined with SpriteRenderers. Perhaps it’s efficient to do a first pass at a level with a tilemap, used for background patterns, then ornament it with SpriteRenderers.
Anything that is
more complicated than a Tile (for example needing unique per instance data, interactable)
non-grid positioned
needs a unique material / shader
could use a SpriteRenderer and GameObject.
the performance will be much worse with sprites, to the point that the game will be unplayable, dont use many sprite renderers as tiles you will regret it
tilemaps creates 1 mesh out of your 10000 tiles, its the most optimization possible
I feel like you misunderstood me. Of course I would not make every single tile into a sprite. What I meant was making entire chunks of levels in graphic editor with copypasting tecnique like ones used for drawing tile palettes and then import them as a whole.
So tilemap renderer uses multiple independent images. Got it. But what about collider then? In case if the first reply was based on my incorrect description too. And what if I use tilemap collider for tile data purposes, but remove renderer and cover this now invisible tilemap with said chunk sprites? Guess tilemap has to store references to images anyway…