Search Unity

[RELEASED] Super Tilemap Editor

Discussion in 'Assets and Asset Store' started by CreativeSpore, Feb 21, 2016.

  1. ryanzec

    ryanzec

    Joined:
    Jun 10, 2008
    Posts:
    696
    @CreativeSpore
    So I have a question about a possible weird use case for Super Tilemap Editor and wanted to get your thoughts on it.

    So I original purchased this assets to prototype a number of different top down game ideas and it has worked great for that, I also tried your smart platformer collider asset to prototype some platformer-ish style games it that went fine too. One other style of game that I am looking to prototype is a terraria / starbound style side scroller sandbox game. Event those this is a side scroller view, I don't think the smart platformer collider package would be that helpful for me here. I am currently prototyping with this assets:

    https://assetstore.unity.com/packages/templates/systems/terrain-engine-2d-115381

    which seems to be the only one of its kind that is geared specific toward this kind of game I want to prototype (even though it is new in its development) however a thought just came to me that while Super Tilemap Editor seems to always be shown with a top down style of game, is there any technical reason why it would not be a good choice for a terraria / starbound style game?

    Thinking about the core features that I would need / want from a tilemap manager for this game:

    ---------------------------------------------------------------------------------------------------------------------------------------------

    Colliders

    I already know with my previous prototypes of top down games that this should work the only difference being is that I would use the physics engine to be able to push the player down instead of not using it with top down games.

    Blocks

    Basically blocks are tiles however one thing I think that terraria / starbound tiles do differently is they have the option to have overlapping so not sure how I might be able to do that with Super Tilemap Editor.

    Destructible / Buildable Map

    I prototyped a top down survival crafting game so I know this asset handle that kind of functionality pretty well.

    Lighting

    I am not sure about this as I have never need to try lighting with any of my prototype so would be interested in your opinion on this.

    Fluid (more of a nice to have)

    This is the most interesting one. Ideally there might be a different asset that I could use with this that could provide 2d fluid functional, again would like to here your thought son this one.

    Performance

    This is pretty much a concern for any game however if I take what I think terraria max map size is, it is a little over 20 million tiles (though I might need multiple layer for background, foreground etc.) but I would think this come down to more or less doing proper culling of what gets rendered and how chunk of rendered tiles are loaded / unload but would like to hear your thoughts on this one too.

    ---------------------------------------------------------------------------------------------------------------------------------------------

    I am definitely going to continue to prototype with the other assets however if that does not work out for me, I would be interested in hearing you thoughts if you think Super tilemap Editor would would be a good choice for this style of game (I don't want to even try it if you think it would be a bad choice).
     
  2. ryanzec

    ryanzec

    Joined:
    Jun 10, 2008
    Posts:
    696
    @CreativeSpore So one other thing I though of that would be a nice to have but not super critical it to have falling tiles but not sure if that is support supported or possible with Super Tilemap Editor.
     
  3. Zebbi

    Zebbi

    Joined:
    Jan 17, 2017
    Posts:
    521
    Sorry if this has been answered before but I'm interested in Super Tilemap and was wondering how it compares with Unity's built-in tilemap editor? I haven't tried Unity's yet and I'm definitely happy to buy the asset, I'm just interested in improvents of workflow, performance and such using Super Tilemap vs built-in. Thanks!
     
  4. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,192
    There is a typo in that method I don't have in my version:
    Should be UpdateChunkRendererProperties not UpdateChunkRenderereProperties.
    Maybe you typed an 'e' by mistake.
     
    gferrari likes this.
  5. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,192
    Here is a list of features that (at the moment I made the list) were not included in the Unity Tilemap System:
    https://forum.unity.com/threads/released-super-tilemap-editor.387330/page-18#post-3287124

    You can check in some review people using Unity Tilemap System have found STME to be very useful.
    I personally found STME more easy to use and more powerful, but I can't be objective about my little creature :D
     
  6. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,192
    Hi there,

    I made STME to be very fast in performance. If you dig in the forum you can find a demo with a procedural map being generate at runtime with a good performance and a lot of posts about this.

    The collider generation is really fast and optimal and is also made in real time creating only the minimum colliders around the areas with colliders. You can also use 3D or 2D colliders and change the collider properties as well.

    For lighting, you can change the tilemap material for SpriteDiffuse to be affected by any light in the scene. Or use the vertex painting to create your own lighting system.

    Using colliders you can use the physics to create any fluid without any problem.

    About blocks, I didn't understood what you mean about overlapping them. But if you need to convert a tile in a gameObject, you can use the TileObjectBehaviour component. Attach the component to a gameObject, create a prefab and attach the prefab to any tile. When you paint the tile, the prefab will be instantiated using the tile as sprite.
    I use it for interactive elements like doors, chests, traps, etc.
     
  7. gferrari

    gferrari

    Joined:
    Jan 14, 2015
    Posts:
    135
    Thank you a lot! I fixed it, but is not my type error, I download it from the assetstore.
     
  8. ryanzec

    ryanzec

    Joined:
    Jun 10, 2008
    Posts:
    696
    @CreativeSpore Thanks for the feedback but let me expand on my overlapping tiles question.

    This is essentially what I think I want to be able to do just from my experience playing around with Starbound as that is the template I am using as least from a visual perspective. Lets say I have my tilemap configured for 16 x 16 tiles however the tiles I want to use are 24 x 24 leaving 4 pixels on each side "overlappping" and each tile would have some sort of order so that if a dirt tile is next to a stone tile, one of them has it overlapping area draw on top of the other tile.

    Let me give you a few screenshots I pulled from Starbound to show you want I mean:

    overlapping-tiles.png

    This shows 2 1 tile width stone stacks with 1 tile in-between. As you can see the space in-between the 2 stone stacks is smaller than the space the stone stacks take up even though they both occupy the same 1 tile width space. On the right you can also see when I fill the 1 tile width empty space with dirt tiles, it overlaps the existing stone tiles making them look smaller in width even though the tile did not appear to change. I am assuming the tiles did not change as when I placed the dirt tiles, not a single pixel of stone tiles changed so I assume the dirt tile is just being drawn on top (now I have no way of knowing this, they could have create the assets so exact so that it did not look like the tile changed but since each tile seems to have a number of different variations and blocks can be placed in any configuration and there are so many different types of blocks in this game, this is my best guess on how they did it at a high level).

    Another Example:

    overlapping-tiles2.png
    overlapping-tiles3.png

    Here you can see what an empty 1 x 1 tile looks like and the difference between what dirt surrounding stone and stone surrounding dirt looks like.

    You can also see this with other kinds of tiles:

    overlapping-tiles4.png

    Again, these are just my best guesses on how Starbound might be doing this based on playing around with it and my best naive guess on the simplest way something like this could be done if I where going to look at implementing it.

    Is this kind of tile "system" possible out of the box with Super Tilemap Editor and if not, any guidance how one might implement such a "system" (with either the way I described or some other way that I might not be thinking of) if possible with Super Tilemap Editor?
     
  9. ryanzec

    ryanzec

    Joined:
    Jun 10, 2008
    Posts:
    696
    @CreativeSpore So I have another question as it relates to building a starbound style map system.

    I figured with having the max map size that I want (6000 x 3000, 20 million tiles) I decided it would be good to split the tiles up into chunks so that the map would not be updating all the time. I decided to chunk the tiles into 30 x 15 groups and based on what I currently feel would be the max zoom out size I would want to support I need to render a size of 9 X 7 chunks around the center of the player (which is 28,350 tiles). If the user were to move at a 45 degree angle, that means when the map needs to update because the player has entered a new chunk, that would require at most 13,500 tiles to be updated (6,750 for the possible new chunks coming into range and the 6,750 tiles for the possible chucks coming out of range that can be removed). This is basically the code that I have for doing that:

    Code (CSharp):
    1. private void DrawWorld() {
    2.     List<int> newDrawnChunks = new List<int>();
    3.     List<WorldChunk> chunksToRender = _world.GetChunksAroundByPosition(_playerGO.transform.position, _renderedChunksWidthRadius, _renderedChunksHeightRadius);
    4.  
    5.     for (int n = 0; n < chunksToRender.Count; n++) {
    6.         WorldChunk chunk = chunksToRender[n];
    7.  
    8.         // no need to drawn chunks if they are already drawn
    9.         if (_drawnChunks.Contains(chunk.Index)) {
    10.             newDrawnChunks.Add(chunk.Index);
    11.             continue;
    12.         }
    13.  
    14.         for (int i = 0; i < chunk.TileIds.Length; i++) {
    15.             Vector2 worldPosition = chunk.GetWorldPositionByIndex(i);
    16.             int worldTileIndex = chunk.GetWorldTileIndex(i, _width);
    17.  
    18.             if (_worldData[worldTileIndex] != 0) {
    19.                 _mainWorldTilemap.SetTileData((int)worldPosition.x, (int)worldPosition.y, _worldData[worldTileIndex]);
    20.                 _environmentTilemap.SetTileData((int)worldPosition.x, (int)worldPosition.y, _worldData[worldTileIndex]);
    21.             } else {
    22.                 _mainWorldTilemap.Erase(new Vector2(worldPosition.x, worldPosition.y));
    23.                 _environmentTilemap.Erase(new Vector2(worldPosition.x, worldPosition.y));
    24.             }
    25.         }
    26.  
    27.         newDrawnChunks.Add(chunk.Index);
    28.     }
    29.  
    30.     // clear up old chunk that are no longer needs
    31.     for (int i = 0; i < _drawnChunks.Count; i++) {
    32.         if (!newDrawnChunks.Contains(_drawnChunks[i])) {
    33.             ClearChunk(_drawnChunks[i]);
    34.         }
    35.     }
    36.  
    37.     _drawnChunks = newDrawnChunks;
    38.  
    39.     _mainWorldTilemap.UpdateMesh();
    40.     _environmentTilemap.UpdateMesh();
    41. }
    In the editor, there is a bit of lag when the player moves into another chunk (which causes this code to run) but in a build it seems to run fine with 2 tilemaps (not sure if I would need more eventually) though since this is probably going to be the biggest bottle neck for performance when the player is moving around (and I have not even gotten to prototyping lighting or liquids), I want to get this code as performant as possible.

    The 2 questions I have are about this are:

    1. Is this the most performant way to handle this kind of map system with Super Tilemap Editor?
    2. Is there anything I could do to make this run faster in the editor or might is just be better to just build debugging tools in the game itself to be able to debug / play around with stuff (which I will want to build at some point anyways)?
     
    Last edited: Dec 3, 2018
  10. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,192
    STME was designed to fit the tiles in a grid, but you can modify the code used to place the tiles to make the tiles bigger or smaller than cell size. Here is where you should add your custom factor. In this case, using 0.5f the tiles will be 50% bigger than cell size:
    upload_2018-12-3_19-56-25.png
     
  11. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,192
    You could use a Coroutine to create the map around the player or camera when it is not visible yet.

    Also, a dictionary for _drawnChunks would be faster than a list.

    Check this post with an example to generate a procedural world in real time. It could give you some ideas.
    https://forum.unity.com/threads/released-super-tilemap-editor.387330/page-9#post-2876541

    About the editor, it is always going to be more slow that a build. I guess you already avoid having the tilemap selected while playing. The drawing of the tile palette consume some resources.
     
  12. ryanzec

    ryanzec

    Joined:
    Jun 10, 2008
    Posts:
    696
    @CreativeSpore So as I am focusing right now on the performance part (as without that, nothing else really matters) so let me try to approach this from a different angle. Instead of trying to do things that might be completely unrealistic, lets say I want to dedicate a maximum of 20% of each frame for rendering / updating the tilemaps leaving 80% for the rest of the game with lighting, physics, UI, game play logic, etc. (and let me know if in your experience if this seems unrealistic for a Terraria / Starbound style game), that would give me about 3.2 milliseconds for that so my questions would be:

    1. In that time frame, what would you say the number of tile I should be able to update would be?
    2. Would the number of tilemaps being updated effect how many tiles I could update (i.e. would updating 10,000 tiles on 10 tilemaps be much slower than updating 50,000 tiles on 2 tilemaps or vis-versa)?

    Also, I did trying the coroutines however with the max speed of the player I am looking to support, that causes slowness in the built version of the game so not sure if that method is really going to help me out.
     
  13. ryanzec

    ryanzec

    Joined:
    Jun 10, 2008
    Posts:
    696
    @CreativeSpore So another thing I was thinking about trying was instead of loading / clearing several thousand tiles at a time, maybe I could have chunks of tiles that are already set and just enable / disable the chunks instead of each tile. I know that Super Tilemap Editor is using at least 1 mesh for rendering the tiles but not sure if it uses multiple meshes or if it is possible to do what I am looking to try to do through the exposed API in order to see if it improves the loading / unload of parts of the world while in it.

    I am sure this might have negative effects when it come to memory usage and initial load up time however if the load up time is only slightly longer compared to any performance gained by just enabling / disable the chunks instead of individual tiles when the player moves around, that might be a trade off I can live with since loading the world is only going to happen once per game session.
     
  14. ryanzec

    ryanzec

    Joined:
    Jun 10, 2008
    Posts:
    696
    @CreativeSpore One last question that relates to another possible idea I have for performance improvements I can try with how I use Super Tilemap Editor is if multiple tilemaps exist with colliders under the same tilemap group and those colliders overlap, would those colliders get merge (so that instead of 2 colliders that would prevent the player from moving from 1 tilemap to the other, there would just be 1 collider and the player could move from one tilemap to the other)?
     
  15. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,192
    It is very difficult to calculate the time dedicated by the tilemap logic. But I can tell you how it works.
    The tiles are rendered using a mesh in a chunk of 60x60 tiles (you can change this size but this value is optimal).
    So, if the chunk area has at least a tile, the tilemap will create a children chunk gameObject to hold any tile in the chunk area, if there is no tiles, no chunk will be created.

    In terms of performance, the chunks that are not visible are not renderer nor updated ( the only thing updated so far are animated tiles ).
    Animated tiles consume some performance because it has to rebuild the mesh.uvs each frame for all the tiles that has animations, no you could avoid animated tiles to improve the performance. But as I said, this only happens for any visible chunk.

    For colliders, each tilemap manages its own chunks, but there is not management for a tilemap group so far. You could check the code in the tilemapChunk_Collider.cs file and apply the same logic to a tilemap group simplifying it to your needs. For example, you should decide how to manage when the same cell has tiles with colliders with different shapes or when a cell size in a tilemap is different for other tilemaps (in your case you could decide to use the same cell size for all the tilemaps so it would be easier to implement).
     
  16. ryanzec

    ryanzec

    Joined:
    Jun 10, 2008
    Posts:
    696
    @CreativeSpore Yea, I have spent all weekend trying to figure out how to get this performant but I just can't. Either I am not grasping some technique games like Terraria / Starbound use or they using some technique(s) that is highly specific to that world style (2d blocky sandbox).

    Thanks for your help anyways.
     
  17. Qzia

    Qzia

    Joined:
    Jan 25, 2015
    Posts:
    138
    Hey,
    since I've been asked, I did my asset support for Super Tilemap Editor.
    I'm still improving it, but it has quite a lot features already!

    You can find Lighting2D asset here
    Smart Lighting 2D Thread

    Untitled (2).png

    Untitled (1).png
    Untitled1.png
     
    CreativeSpore likes this.
  18. ryanzec

    ryanzec

    Joined:
    Jun 10, 2008
    Posts:
    696
    @CreativeSpore

    So I think I have made a pretty big breakthrough in getting performance much better however there is just one slight issue with it.

    First, what I tried was instead of rendering all 77 16x16 chunks of tiles that I was generating in 1 tilemap, I just rendered each chunk in their own tilemap (so 77 16x16 tilemaps) and just placed them next to each other in the correct order. I basically pre-allocate a pool of 100 tilemap game objects and just recycle through them as the player moves around.

    When I was just using 1 tilemap I averaged about 1400 FPS when moving across all 5920 tiles width wise at a max supported character speed however the map was mostly lagging behind where the edge of the screen where the character was moving towards was blank as the rendering was trying to catch up to the movement and the FPS dropped to or below 30 FPS 352 times, the lowest was 5 FPS (over a total time of ~31 seconds)

    With using multiple tile maps, I averaged about 2100 FPS but more importantly the map never lagged behind and the FPS only dropped to or below 30 FPS 3 times, the lowest was 27 FPS (over a total time of ~31 seconds).

    You can correct me if I am wrong but I am assuming the reason the performance is better and more consistent is that it is more efficient to update several smaller meshes / many smaller colliders instead of trying to update 1 large mesh / fewer larger colliders when only a small part of the tilemap changes (with the 77 tilemaps, only 17 of them can possibly change at once at any given time).

    Now the issue I run into with this is that brushes don't really work with this setup:

    STE-multiple-maps.png

    You can see where the 16x16 tilemaps are just by looking for the solid dirt lines that repeat.

    This is not a surprise since using multiple tilemaps means the tilemaps next to each other don't know about the tiles next to them on the edges (at least not from the tilemap data itself, the data I am generating to populate the tilemaps does have access to that data).

    I was wondering if there was a way built into Super Tilemap Editor to be able either have multiple tilemaps know about each other / be able to be given extra data that would help enable brushes in this kind of setup or if there was a way to tell Super Tilemap Editor to render multiple chunks / meshes instead of just 1 big mesh / as few colliders as possible (I know there is chunking already at some level but it seems like colliders cross over the chunks and I assume the mesh does as well) or would I have to basically write my own code that generated the tile ids from the full set of data that I am generating and using to render the tilemap and basically re-implement brushing that way for my own needs?
     
  19. ryanzec

    ryanzec

    Joined:
    Jun 10, 2008
    Posts:
    696
    @CreativeSpore I decided to do a few more benchmarks this morning just to try to see what might be causing more of the issue, the rendering of the mesh or the colliders and also test examples with multiple layers since I will be needing that anyways. All tests were done on a map of 5920x3040 tiles but only rendering 176x112 at a time with 7 16x16 chunks loading and 7 16x16 chunks unloading when the map updates (same parameters were used for the tests I mentioned above). I move the character at the maximum support speed across all 5920 wide tiles from right to left over the coarse of 31 seconds.

    2 Layers (neither with colliders)

    The first additional test was to add another layer (so +1 tilemap for the 1 tilemap per layer group and +100 tilemaps for the 1 tilemap per chunk group) and have neither layer have colliders:

    2 Total Tilemaps, no colliders:
    • Average FPS: 1650
    • Minimum FPS: 13
    • Number of frames under 30 FPS: 312
    200 Total Tilemaps, no colliders:
    • Average FPS: 2050
    • Minimum FPS: 27
    • Number of frames under 30 FPS: 4
    2 Layers (1 w/ colliders | 1 w/o colliders)

    The first additional test was to add another layer (so +1 tilemap for the 1 tilemap per layer group and +100 tilemaps for the 1 tilemap per chunk group) and have 1 layer with colliders and 1 layer without colliders:

    2 Total Tilemaps, 1 will colliders and 1 without collider:
    • Average FPS: 770
    • Minimum FPS: 4
    • Number of frames under 30 FPS: 315
    200 Total Tilemaps, 100 will colliders and 100 without colliders:
    • Average FPS: 1830
    • Minimum FPS: 20
    • Number of frames under 30 FPS: 20
    2 Layers (both layers with colliders)

    The first additional test was to add another layer (so +1 tilemap for the 1 tilemap per layer group and +100 tilemaps for the 1 tilemap per chunk group) and have both layers with colliders:

    2 Total Tilemaps, both with colliders:
    • Average FPS: 5
    • Minimum FPS: 4
    • Number of frames under 30 FPS: 305
    200 Total Tilemaps, all wwithil colliders:
    • Average FPS: 5
    • Minimum FPS: 4
    • Number of frames under 30 FPS: 302
    Based on this it seems that even though just the mesh alone does cause slowness and jankyness in the game, the colliders are taking up a lot of the time.

    Not sure if this is useful for you but figured I would share the results.
     
  20. zyend36

    zyend36

    Joined:
    Dec 14, 2018
    Posts:
    2
    Hi all,

    I've developed a Game engine in c++/OpenGL.
    Now I've started implementing a "breakout" Arkanoid like game for my kids.
    To design the levels, I plan to use "Super Tile Map Editor"...although I'm not at all familiar with Unity engine.

    My questions are:
    • Is it possible to design levels and export them into a human readable format (xml or ...) ?
    • Is it possible in the editor, to create some "layers" whose tiles wouldn't have the same size ?
      That is: the Background layer would be based on a 32x32 tiles whereas the "bricks" layers would rather be based on 32x20 tiles ?

    Thanks for your feedback.

    Z.
     
  21. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,192
    You can change the size of the chunk here. It is more efficient than creating multiple tilemaps of 16x16.
    But take into account changing the chunk size will break previous tilemaps created with a different chunk size.
    You could try using a size of 8 that will enable dynamic batching and check how it the performance.
    (see the image below)
    upload_2018-12-14_11-32-5.png
     
  22. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,192
    Yes, you can also serialize your maps. This post will help you with that:
    https://creativespore.com/2018/07/03/how-to-iterate-a-tilemap/

    Also, you can change the tilemap cell size of any tilemap:
    upload_2018-12-14_11-37-7.png
     
  23. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,192
    Qzia likes this.
  24. ryanzec

    ryanzec

    Joined:
    Jun 10, 2008
    Posts:
    696
    @CreativeSpore Ok, I will give that a try.

    One other question I have relating to this is brushes. I am using the 47 brush for pretty much everything and was wondering if you think that would also be part of my performance concerns? For example If I move back and forth the same set of tiles are going to be removed and added over and over again and I assume each time the brush is re-calculating the tiles as the player come closer to them. Not sure if that is something I need to cache since the player moving would not effect that so the calculation of the tile should only happen once (which could happen on generating the map data) and then only on actions that would cause the map to change.

    I know sometimes certain features are not designed to be usable for all situations and was wondering if brushes are a case where they are more designed for maps that are built ahead of time (whether in the editor or at runtime) for relatively static maps and not ideal if your map is going to be dynamically changing all the time like mine is as doing to performance testing seems to be shown the brushes actually have more of an impact in the performance than the collider generation does.
     
    Last edited: Dec 15, 2018
  25. zyend36

    zyend36

    Joined:
    Dec 14, 2018
    Posts:
    2
    Thanks for your quick feedback.
    Ok for the multiple layers grouped in "TileMapGroup".

    But I'ven't understood how the "exporting" process is done ?
    Is there in the software, an exporting option ? like "export as XML file" or whatever ?

    That's seems confused for me .

    Thanks.

    Z.
     
  26. ryanzec

    ryanzec

    Joined:
    Jun 10, 2008
    Posts:
    696
    @CreativeSpore In the effort to be as through as possible, I did some deep profiling, this was the setup for the profile:
    • 2 Tilemaps both with edge colliders
    • Each tilemap being render with the same tiles (rendering 88 x 72 tiles or a total of 6336 tiles at once)
    • Using default 60 chunks size (as changing that did not have a noticeable effect before I did this profile)
    • Every time the player moves 8 tiles, a set of 576 tiles are removed and a set of 576 tiles are added
    I decided to take the frame that had the highest time which was this:

    profiler-deep-one.png

    Basic Numbers:
    • Total Behaviour Update: 1722.59ms
    • ------------------------------------------------
    • STE Update: 1641.14ms
    • STE Erase: 39.41ms
    • STE SetTile: 37.60ms
    • ------------------------------------------------
    • STE Total: 1718.14ms (or ~99.7% of all behaviour update)
    So while I am sure I could make some optimization in the data structures and how I process them, it seems like that is not going to make much of a difference here.

    Now while I would not be surprise the deep profiling might skew the results slightly (maybe the STE code is less than 99.7% when running in the editor or full build), I imagine that it should be relative representative (or maybe I don't understand the profiler or am not using it correctly).

    I did the deep profile on the 1 tilemap per layer instead of the 1 tilemap per chunk per layer since you said that it should be more efficient but if you want me to do the same test on the other setup (or drill down deeper into anything with this profile or want the profile data yourself), let me know as using multiple tilemaps per chunk is still noticeably more performant for me.
     
  27. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,192
    No, there is no option to export the tilemap as an xml. But the tilemap data is very easy to import. All the data of each cell of the tilemap is hold in a single integer.
    When you call tilemap.GetTileData(gridX, gridY) you get an integer that you could later set in a clean tilemap with tilemap.SetTileData((int)tileData).

    Only thing you need to hold in the scene is an empty tilemap with the right tileset or create one in realtime.
     
  28. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,192
    Thanks for your time profiling the tool and for sharing what you found.
    It looks I added a Debug.Assert that is causing the issue. At least most of it.
    It is only affecting the Editor, but it can be fixed to improve the performance in the Editor.
    I have attached the fix in this post.

    Also, you can comment the TangentSolver and RecalculateNormals method if you are not using directional lights.
    upload_2018-12-17_21-11-44.png
     

    Attached Files:

  29. ryanzec

    ryanzec

    Joined:
    Jun 10, 2008
    Posts:
    696
    @CreativeSpore Cool, glad my barrage on posted resulted in you finding a small issue. I did try to apply that fix but did not see any real improvement but that might be because I already decided to go with the multiple 16x16 tilemaps instead of one big one because from all my testing, that was the way to get the best overall performance (my overall FPS went down from something like 2600 to 2200 but it also removed any lag when adding / removing chunks which is way more important).

    Not sure if you saw my question related to brushes, can't blame you if you didn't as I tending to post a lot as I post immediately as I find something instead of trying to collect them together in larger post (sorry about that).

    Most of the tiles in my game are going to be 47 brush based tiles and I noticed that when I using a single tilemap, there was a major difference in the lag when updating the tilemap when using brushes vs not using brushes. This lead to my assumption that if I add say 256 tiles to a map that currently has 10000 tiles being rendered that the logic for determining each tile based on the brush was being executed for all 10000 tiles instead of just for the new tiles and are tiles around the tiles added (as anything that is not near a new tile would not change and therefore the brush code would be running on like 9700+ tiles that is does not need to wasting performance) . I don't know if this assumption is correct.

    My question with brushes: Is that feature designed to be used at runtime with large dynamically changing worlds? If my assumption above is correct that I would say that was probably my #1 performance issue I was seeing (even thouhg I think there were others). I am not sure if brush calculations are cached somewhere and only recalculated if a tiles nearby changes or not. I think it is fine if brushes might not be designed for the use case I need (which might make sense since my use case is far more on the edge case side than the common one) but was just curious how brushes work internally a little bit to know.

    I have basically created a custom world manager that calculates the brushes ahead of time when the map is generated and then just send the calculated tiles to STE and with that I am able to get the effect of brushes in the map without the lag that was previously there. I will also write code so that whenever a tile is updated, only the surrounding tiles recalculate their brush tiles which should result in the minimal amount of work needed to keep the map looking correct (this part is the next thing I am going to code, so not 100% sure if it will work but I am optimistic based on the results of the first part I have coded).

    I think with my game, I ultimately need to have a custom world manager anyways because the world is going to be filled with a ton of different thing that I want to render to the screen as tiles that need custom functionality and having a game object per tile for this those things is not going to scale so I am going to need to manage the logic with a single manager script so that I can manage all of it with one game object. This does mean all tiles that I would to use brushes for (like 47 tiles, animated tiles, etc.), I will need to create logic for but that is something that I expected I might have to do anyways.

    STE still provides me with the two biggest things I did not want to have to worry to much about and that was the management of rendering of the tiles to a mesh and keeping the colliders updates based on changes. Again, thanks for providing this awesome asset with fantastic support too.
     
  30. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,192
    I answer you below:

    I already decided to go with the multiple 16x16 tilemaps instead of one big one because from all my testing, that was the way to get the best overall performance (my overall FPS went down from something like 2600 to 2200 but it also removed any lag when adding / removing chunks which is way more important).

    Did You tried to change the chunk size? I think it would give you better performance and would be easy to implement.

    my assumption that if I add say 256 tiles to a map that currently has 10000 tiles being rendered that the logic for determining each tile based on the brush was being executed for all 10000 tiles instead of just for the new tiles and are tiles around the tiles added

    The tiles has a flag called Updated that is set to indicate that the tile doesn't need to update again if it is using a brush. But this flag is removed if you update the tilemap using the Refresh method with he option refreshBrushes to true. Most of the time, you should update the tilemap using the UpdateMesh method.

    My question with brushes: Is that feature designed to be used at runtime with large dynamically changing worlds? If my assumption above is correct that I would say that was probably my #1 performance issue I was seeing (even thouhg I think there were others). I am not sure if brush calculations are cached somewhere and only recalculated if a tiles nearby changes or not. I think it is fine if brushes might not be designed for the use case I need (which might make sense since my use case is far more on the edge case side than the common one) but was just curious how brushes work internally a little bit to know.

    When you set a tile with a brush, the tile and all surround tiles set the Update flag so when the tilemap is updated, only those tiles are updated calling the brush refresh method.

    About your last questions, you shouldn't need to manage the update of tiles and surround tiles. I have checked it again, just in case I broke it with a previous change, but it still works as it should.
    It should be something related with the way you are updating the tilemap.
    You can add this line to debug what is happening and when is the brush refreshed:

    Debug.Log("Refreshed brush " + (GridPosX + tx) + ", " + (GridPosY + ty));

    upload_2018-12-22_11-28-49.png
     
  31. DanielThomas

    DanielThomas

    Joined:
    Mar 30, 2013
    Posts:
    110
    Hi,
    I'm a playmaker user and had a question about how I can get the brush used in a tile and reuse that brush?
    What I'm doing is I get the tile data, I want to store the brush used in a variable. And later on, I want to use this variable to draw a tile with.

    At the moment it only seems to be possible to get brush ID int, but also no way to use a variable with a brush when using the draw actions.

    Is this possible at the moment or something that could be sorted out?
    Thanks!
     
  32. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,192
    Did you try using the Draw Tile Chunk action?
    What you need to save is a pattern and use this action to paint it.
    upload_2019-1-3_12-41-29.png
     
  33. DanielThomas

    DanielThomas

    Joined:
    Mar 30, 2013
    Posts:
    110
    @CreativeSpore Hmm, I think we missunderstand eachother.
    For an example, if I'm trying to do a game where the player build different kind of roads. So this would require me to be able to change the 'pattern/tile' that is drawn depending on which road the player has selected. So basically it would be a variable that contains the current selected road(which is a 'carpetbrush' object variable).

    Another questions was if there was a way to get tile data and find the current tilebrush on the tile and store it in a object variable ('carpetbrush object' in my case)

    I hope that was more clear. In short I'm trying to store brushes in variables and paint with the variables at runtime - with playmaker.
     
  34. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,192
    Ok, so what you need is to use this to get the information of a tile:
    upload_2019-1-7_12-51-25.png
    Using this action you can save the brush id and later use the Set Tile Data action to set that brushId in any tile.
     
  35. DanielThomas

    DanielThomas

    Joined:
    Mar 30, 2013
    Posts:
    110
    This was my initial idea, but I wasn't able to find any _set_ tile data action. I reimported the playmaker actions from the asset store. When I take a closer look it doesn't seem like I have any of the "set tile" actions (only the get ones), and the opposite with "set tilemap" actions. Could you confirm these are in the asset store package and I'm having some kind of import problem?

    A quick note, I think there is a typo in one of the actions:
    SetTilemapChunkRendererProperties.cs(61,25): error CS1061: 'STETilemap' does not contain a definition for 'UpdateChunkRenderereProperties' and no accessible extension method 'UpdateChunkRenderereProperties' accepting a first argument of type 'STETilemap' could be found (are you missing a using directive or an assembly reference?)

    Fixing the type fixed the error.
     
  36. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,192
    I have updated the asset and it was approved 2 hours ago. Check this new version. You should see a SetTileData action now and have the typo error fixed.
     
  37. DanielThomas

    DanielThomas

    Joined:
    Mar 30, 2013
    Posts:
    110
    It's still showing the old version, I'll check again later tonight. Sure it had "publish automatically after approval" ?
     
  38. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,192
    I have checked it and it is available now.
     
  39. DanielThomas

    DanielThomas

    Joined:
    Mar 30, 2013
    Posts:
    110
    It's in the store, but it won't download. Other assets does download (so it's not a firewall problem or similar). Something I noticed is that the asset store say its size is 0mb and has 0 files, maybe there was a problem when uploading it?
     
  40. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,192
    Yes, it looks like there was a problem with the submission. I have resubmitted it again. Here you can download the updated package.
     

    Attached Files:

  41. DanielThomas

    DanielThomas

    Joined:
    Mar 30, 2013
    Posts:
    110
    Perfect, thanks!
     
  42. gferrari

    gferrari

    Joined:
    Jan 14, 2015
    Posts:
    135
    Hello, someone would be so kind to pass me a topdown character controller (just move) with pathfinder for super tilemap editor. I can´t make a decent one :( Thank you very much.
     
  43. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,192
    I hope this helps you.

    This is a tutorial game I was doing for Super Tilemap Editor.
    You can find more information here:
    https://creativespore.com/2017/12/0...h-super-tilemap-editor-temple-of-doom-part-1/

    It includes a simple top down character controller and some framework to make a game with point and click control.
     

    Attached Files:

    gferrari likes this.
  44. LiberLogic969

    LiberLogic969

    Joined:
    Jun 29, 2014
    Posts:
    138
    Hey, When I import v1.6.0 (which I believe is the newest version?) into Unity 2018.3.3f1 I get a buttload of compile errors relating to Tiled Importer and PyxelEdit (IIRC). I've deleted all of those folders since I didn't need the functionality but I also had to comment out some editor code to resolve every error. Just giving a heads up! Thanks for the awesome asset!!!
     
    CreativeSpore likes this.
  45. jebediahh

    jebediahh

    Joined:
    Feb 20, 2017
    Posts:
    26
    Hi - I'm creating a procedurally generated map with code and I'm wondering if there is a way to get the actual tile that was placed by a carpet brush. That is, I have a brush which is defined by some tiles... In code, i'm just placing the brush ID for that brush everywhere I want it to go, and then your code does the job of deciding which actual tile to place based on the brush logic. But..how do I get the actual tile that was placed there so I know what type of tile is in that position?
     
  46. Paulo_Ferrato

    Paulo_Ferrato

    Joined:
    Nov 26, 2018
    Posts:
    4
    Hey man! Just a little question... How can I get the specific sprite of a Tile? I mean.. I can get the brush ID, the TileData, and everything. Could I get the sprite? Or the rect and Texture2D? It also would help if i could get a Texture2D or sprite from your TileChunk.

    Anyways.. Big fan of your work. Great job!
     
  47. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,192
    PyxelEdit can be removed if you are not using Pyxel Edit to create your levels, but I will check all warnings and error in that version and upload a new version with all that fixed.

    EDIT: I have reimported the version 1.6.0 in Unity 2018.3.4f1 and I had no compile errors. Maybe it was a problem with the serialization?
    What I see is some warnings that I will fix for the next version but shouldn't be a problem.
     
    Last edited: Feb 8, 2019
  48. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,192
    Here you can see a lot of example of how to get data from a tilemap cell like the brush, the tile, etc:
    https://creativespore.com/2017/10/23/editing-tiles-of-an-stetilemap-from-script/

    You can also check the TilemapUtils class with lots of useful helper methods.

    If you need more help don't hesitate to let me know.
     
  49. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,192
    You can get all data with the info of the previous post.
    You cannot get the sprite nor the texture2D of a single tile because it is part of the atlas texture.
    You can get the UV rect if you get the Tile data with tilemap.GetTile().

    But it could be interesting to check the component TileObjectBehaviour.
    This component creates an sprite from a tile when it is attached to a prefab assigned to a tile.

    By the way, thanks for your kind words by the way and for being a big fan ;)
     
  50. Paulo_Ferrato

    Paulo_Ferrato

    Joined:
    Nov 26, 2018
    Posts:
    4
    Hey man! It's me again. Your answer helped me a lot. I'm trying to make some mask interactions with the tilemap. Until now what i got is one big sprite mask being created and updated with the tilemap. The problem is: I'm using GetPixel Tile by Tile, so this process cost too much fps. Is there a way to use and configure the mask directly in your TileMap Chunk? Or maybe use the Mesh that's in it instead of using the Tile? See, I need the mask to be editable in game and it'll have interactions in two ways with masks, to be visible inside of one mask and outside the other.