Search Unity

[RELEASED] Super Tilemap Editor

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

  1. MaximovInk

    MaximovInk

    Joined:
    Oct 17, 2016
    Posts:
    9
    Sorry :d
     
  2. MaximovInk

    MaximovInk

    Joined:
    Oct 17, 2016
    Posts:
    9
    Hi, I have a question, how to make smooth or pixel-by-pixel transitions between tiles?

    This is not good:
    upload_2019-4-30_20-7-50.png
     
  3. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,091
  4. MaximovInk

    MaximovInk

    Joined:
    Oct 17, 2016
    Posts:
    9
  5. MaximovInk

    MaximovInk

    Joined:
    Oct 17, 2016
    Posts:
    9

    Attached Files:

  6. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,091

    Attached Files:

    MaximovInk likes this.
  7. MaximovInk

    MaximovInk

    Joined:
    Oct 17, 2016
    Posts:
    9
    What better way to do?
    if I use the Edge Collider, the player can get stuck in the Collader itself.But if you use a polygon collider, then the player pushes out of small spaces.
    Polygon:
    upload_2019-5-1_21-20-6.png
    Edge:
    upload_2019-5-1_21-21-6.png
    P.S. There is one solution: will I use tile objects for this, or is there something more correct?
     
    Last edited: May 1, 2019
  8. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    769
    Hi, I've been trying to make my own custom TilesetBrush that allows me to define "interior walls" but I'm having a hard time figuring it all out. Instead of ripping all my hair, I thought that maybe someone could have done it already.

    Any hints on how to achieve something like the image attached?
     

    Attached Files:

  9. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,091
    The problem when using polygon colliders is that they are a closed area. Imagine them as if they were filled inside the area. I prefer to use Edge Colliders and use a raycast check from previous transform.position (saved each Update) and the current transform.position to check if something has collided the edge collider. If the entity has a big collider and is not moving fast you don't need that. It is mostly for bullets.

    Now, if you want to use the polygon colliders, a trick is don't close the area completely. For example, you can leave a block empty for the entrance and place the door in another tilemap or using an prefab with a collider on it.
    Also, you can change the collider of a wall corner so it breaks the seamless colliders:
    upload_2019-5-2_11-27-48.png
     
  10. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,091
    You could use the CarpetBrush as template because in case you want to use subtiles (dividing a tile in 4 subtiles to reduce the number of tile combinations in your atlas) or you could use the brush47 if you want to create all the combinations for each tile.
     
  11. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    769
    Thanks! The brush47 almost gives me the results I want but "inverted". To get what I want, I need to remove the tiles instead of adding them. Also, I don't want the outer border.
    See the image attached. What I want is the inner border without the rest. Is it possible with any of the built-in brushes?
     

    Attached Files:

  12. lostdragon

    lostdragon

    Joined:
    Mar 23, 2014
    Posts:
    48
    For people coming along later - anyone using the example method that finds the first visible tile in a tilemap group: (see several posts above mine for full code) must add:



    using System.Linq;



    To the top of their code.

    Otherwise you will get an error:

    Error CS1061 'List<STETilemap>' does not contain a definition for 'OrderBy' and no accessible extension method 'OrderBy' accepting a first argument of type 'List<STETilemap>' could be found (are you missing a using directive or an assembly reference?) Assembly-CSharp
     
    CreativeSpore likes this.
  13. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,091
    You can do that in the opposite way. Fill a big area and then remove the tiles from the inside.
     
  14. mrm83

    mrm83

    Joined:
    Nov 29, 2014
    Posts:
    220
    We have many maps, and each maps has multiple layers (groups). Every layer contributes the memory and it gets very heavy on mobile. Each map is also 180x180 in size.

    Is there an option to combine multiple groups into a single map?
     
  15. vambier

    vambier

    Joined:
    Oct 1, 2012
    Posts:
    44
    I have a problem getting the correct tile hit by a raycast. I'm doing it like this:

    Code (CSharp):
    1. STETilemap tilemap = raycastHit.transform.GetComponentInParent<STETilemap>();
    2.  
    3. if ( tilemap )
    4. {
    5.     Vector2 localPos = tilemap.transform.InverseTransformPoint(raycastHit.point);
    6.     int gridX = BrushUtil.GetGridX( localPos, tilemap.CellSize );
    7.     int gridY = BrushUtil.GetGridY( localPos, tilemap.CellSize );
    8.     Debug.Log("x = " + gridX + " y = " + gridY);
    9.     CreativeSpore.SuperTilemapEditor.Tile tile = tilemap.GetTile(gridX, gridY);
    10. }
    In my example scene I expect the tile 7, -5 to be hit, but the outcome of the above code is tile 7, -4, that's the tile right above it.
    I'm guessing this is because the point returned by the RaycastHit2D is just above the collider that is hit, so it's actually in the tile above it. Is there a way that I can corectly get the tile that I hit with a raycast? I know I can add a small margin to the point returned by the RaycastHit2D, but that seems a bit dirty.
     
  16. hunttis

    hunttis

    Joined:
    May 4, 2019
    Posts:
    1
    Hi!

    Just bought the plugin and loving the drawing features. I ran into a strange issue, when building a web (or mac build). When running in the editor, everything works fine, but in those builds, the STETilemap doesn't exist.

    I have a SuperTilemapEditor Tilemap object that is tagged with "Foreground" and I'm accessing it like this:
    GameObject.FindWithTag("Foreground").GetComponent<STETilemap>();

    It never seems to resolve to an object however (in those builds). It does contain the components in the following image. Am I accessing it wrong?

    The usecase is that I need to figure out what is the tile below the tile on which the mouse cursor is. In other words: Is there ground beneath the tile where the cursor is.

    Did I run into a bug, or am I going about this in a silly way?

    I am using the newest 2019 unity, which is not listed in the compatible versions you say in the description, but I was still hoping it would work :D
     

    Attached Files:

  17. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    769
    Hi,

    I'm manually doing a "flood fill" operation doing something like:

    Code (csharp):
    1. var brush = BrushBehaviour.GetOrCreateBrush(backgroundTilemap);
    2. brush.FloodFill(backgroundTilemap, brush.Offset + tilesPositions[0] + Vector2Int.one);
    However, this uses the currently selected tile on the palette. Is there any way to tell it to use a specific tile instead?
     
  18. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,091
    No, there is no way to do that automatically. You could combine them by code on play if you don't need to render more than a tile in the same place.
    But there some tricks to reduce the memory budget:
    • Animated tiles consume more memory to manage the tile animation
    • Adding colliders to the tilemap also cosume more memory to generate the tile colliders.
    • Using the Color Channel also increases the memory to save the color of each vertex
    • The CarpetBrush, using sub tiles, generates 4 small tiles per tile so the mesh data per tile is multiplied by 4.
    • Placing tiles with attached prefabs also increase the memory per tile
     
  19. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,091
    Yes, use the TilemapDrawingUtils class. The FloodFill method receives a 2 dimensional array in case you want to use a tile pattern.

    Code (CSharp):
    1.  
    2. TilemapDrawingUtils.FloodFill(tilemap, gx, gy, new uint[,] { { tileData } });
    3. tilemap.UpdateMesh();
    4.  
     
    luispedrofonseca likes this.
  20. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,091
    I guess for your description of the problem that the raycast is thrown over the 2D plane.
    I think the best way to find the tile would be adding a small displacement in the raycast direction. It could look like dirty, but it is the right way to do this because otherwise you would have precision errors if you try to find the tile at a position that is just over the tile edges.
     
  21. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,091
    It looks like a but. I found many in IOS builds. Maybe the problem is that FindWithTag if finding another gameObject with the same tag but no STETilemap component.

    Anyway, you can solve your use case if you use this code:

    Code (CSharp):
    1. int gx = TilemapUtils.GetMouseGridX(tilemap, Camera.main);
    2. int gy = TilemapUtils.GetMouseGridY(tilemap, Camera.main);
    3. Tile tile = tilemap.GetTile(gx, gy);
     
    hunttis likes this.
  22. LiberLogic969

    LiberLogic969

    Joined:
    Jun 29, 2014
    Posts:
    138
    Is it still possible to make a Fog of War effect like in older RTS games with STE? I'm messing around with making a turn based classic rogue style game. I know at one point the Rogue demo scene had Fog Of War but it seems to be gone now, and I never looked into how it worked.
     
  23. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,091
    I think the scene you remember is the one included in https://assetstore.unity.com/packag...ing/playmaker-for-super-tilemap-editor-100165

    You can create a fog of war using a black or tinted tilemap for the fog and drawing on it using the TilemapVertexPaintUtils.VertexPaintCircle method to set the color to Color(1, 1, 1, 0) using the BlendingMode to None.

    It should work removing the area around the VertexPaintCircle position.
     
  24. antonioperez80

    antonioperez80

    Joined:
    Jun 8, 2017
    Posts:
    1
    Hello, I just acquired super tile map. Can you explain me how to use the pathfindind scripts? Thank you.
     
    gferrari likes this.
  25. lepus525

    lepus525

    Joined:
    Dec 26, 2017
    Posts:
    3
    HI, I'm super happy with Super Tilemap Editor XD
    Sorry for my English. I'm not a English user.
    I tried carpet brush made with random brushes of animated brushes.
    (animated brushes -> random brushes -> carpet brush)
    and animation didn't work. It's just not moving. T^T
     
  26. mrm83

    mrm83

    Joined:
    Nov 29, 2014
    Posts:
    220
    Only 2 points affect us right now:
    Our maps have colliders, we need it for collision detection, so this must stay.
    All our tiles are based on CarpetBrush, is "Sub tiles" the 4 square tiles at the bottom? How to not use it? Because if those 4 tiles are left blank, the rendered map will have holes where those 4 squares would show up.
     
  27. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,091
    Did you activate this checkbox?
    upload_2019-5-26_10-36-32.png
     
  28. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,091
    For the colliders, you try to place all in the same tilemap if possible. Also, try using Full collider mode for all of them.
    It will reduce the number of colliders vertices in the level.
    You can use the Brush47 instead of the CarpetBrush to avoid using subtiles, but you will need to create all combinations as a single tile in the atlas.
     
  29. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,091
    You can see an example of use in PathfindingBehaviour.cs.

    I will explain the Synchronous mode because it is simpler than the asynchronous mode, but the only difference is the asynchronous uses a coroutine to avoid waiting for the path computation to end.

    So, when you touch the screen, the path is computed in this chunk of code:
    upload_2019-5-26_11-24-46.png

    UpdatePathSync receives a start position that is the position of the gameObject and an end position, that is the position when the mouse was when you click the screen.
    upload_2019-5-26_11-27-31.png

    Now, the start and end position are passed to the PathFinding property that is a MapPathFinding instance with all the parameters to find the path:
    upload_2019-5-26_11-30-2.png

    Here you can setup the pathfinding to include colliders, for example, a maximum distance for the path, etc
    By default, a tile will be considered blocked if generates colliders (Collider Type != None).

    GetRouteFromTo will return a linked list of nodes with the center position of each tile of the result path if a path was found.

    ProcessComputedPath just polish the result a little bit. Some Heuristics like Manhattan are faster but could make a not polished path, so this computation just try to optimize the path a little.

    I hope it is more clear now ;)

    Let me know if you need more help.
     
  30. Woofo

    Woofo

    Joined:
    Aug 10, 2017
    Posts:
    2
    Very late response but in case it's still useful as reference, I created something for this use case a while back. It has some limitations, mainly it currently only works if the tiles are in the same tilemap. I'd like to extend it to check all the tilemaps in a group, but life has gotten in the way and I haven't had much time for Unity lately.

    https://forum.unity.com/threads/released-super-tilemap-editor.387330/page-19#post-3293326
     
    CreativeSpore likes this.
  31. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    769
    @Woofo Thank you very much for that. I actually already changed my workflow so I don't need this anymore, but thanks for sharing. It looks great and might be useful in the future!
     
    Woofo likes this.
  32. lepus525

    lepus525

    Joined:
    Dec 26, 2017
    Posts:
    3
  33. lepus525

    lepus525

    Joined:
    Dec 26, 2017
    Posts:
    3
    When I draw just 1 tile in (animated random) carpet brush, it moves.
    But when I draw more tiles continuously in same brush, it stops moving.
     
  34. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,091
    After checking the code, I've seen that only a linked brush is allowed. The combination Animated + Random + Carpet won't work unless you create a custom Brush with support for all this.
     
  35. Andrew122222

    Andrew122222

    Joined:
    Jul 8, 2012
    Posts:
    28
    Without reading through the entire thread, is there a way for this plugin to handle the case specified here:
    https://github.com/Unity-Technologies/2d-extras/issues/46

    Basically, a *single* brush that can draw
    edges/floor/roof/walls, then have inner tiles that act as a transition going from the tile colour toward black, then the inner most tiles be black. When I experimented with this plugin a year or 2 ago I couldn't do this. Is it possible now?

    My current solution involved two brushes. One for drawing the main tiles to walk on, then a decorative set of tiles for drawing the inside.
     
  36. zh4r0naX

    zh4r0naX

    Joined:
    Oct 30, 2016
    Posts:
    24
    Hey @CreativeSpore will it work on Unity2019.x ? I need to upgrade i guess and i dont want to use their tilemapsystem.
     
  37. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,091
    I didn't try and I don't know if it could work. But did you try to use a RoadBrush using another brush for the inner tile?
    Also you need to set the inner brush to autotile with the other brush or directly set autotile with everything.
     
  38. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,091
    It should work with the last version. I've been updating the asset to support the last versions and in case you find any issue with a new release, let me know and I will find a solution and send you a patch.
     
  39. themadmuffin

    themadmuffin

    Joined:
    Feb 21, 2019
    Posts:
    21
    I am having a bug with the Groups and Autotiling functionality. Version is latest, 1.6.2

    I have a group that consists of two Carpet Brushes. I want one to autotile with the other, so I set that one to tile with Group. This works, but it doesn't tile with the borders of my map, so I also select Tile With Map Borders.

    As soon as I do this, it starts autotiling with the edges of my map, but stops tiling with the other brush in it's group. The Brush still shows its check off both only Group and Tilemap Bounds, but it doesnt tile with the other brush in the group.
     
    Last edited: Jun 20, 2019
  40. ryanzec

    ryanzec

    Joined:
    Jun 10, 2008
    Posts:
    659
    @CreativeSpore So I am noticing an issue with the performance of creating maps in the editor. This is for a 64 x 64 sized map.

    When I pull a prefab with a tilemap and edit it in a scene everything works fine however it I try to modify that same prefab in frefab mode, modifying the map is extremely slow and can sometimes just bug out.

    While I have a workaround right now, I am basically using prefabs as levels so would would be incredibly useful to be able to use the tilemap editor while in prefab mode without issue.

    This is with version 2019.1.4f1.
     
  41. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    9,518
    @ryanzec - Try unticking Auto Save in the upper right of the scene view.
     
    CreativeSpore likes this.
  42. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,091
    I guess this is because the new prefab mode saves the asset each time you make a modification. Use the @ryanzec solution to avoid that.
     
  43. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,091
    I added a new autotiling mode. Maybe that is causing the issue. I will check it and let you know as soon as I find the bug
     
  44. ryanzec

    ryanzec

    Joined:
    Jun 10, 2008
    Posts:
    659
    My solution is to drag the prefab into a scene modify and sync it bad which is less than ideal. I also thought it was the auto saving stuff however even when I turned auto save off, the performance was not good (better than with it on but since less than what I would consider usable).

    It does seem like if I disable the auto save and disabled undo for the map, the performance comes back to what I would expect so I there is that.
     
    CreativeSpore likes this.
  45. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,091
    I fixed an use case where the tilemaps contained in prefabs were being saved. If you are not using the last version, you could try to update the tool.
    If you are in the last version, I guess it is caused by a use case related with Undo operations but it is good to know disabling it fix the issue.
    Anyway, if I see something I will try to fix it for the next version.
    Thanks for reporting your solution ;)
     
  46. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,091
    I have attached the patch in the post.
    Also I have attached another fix for the hot control warnings as well.
     

    Attached Files:

  47. themadmuffin

    themadmuffin

    Joined:
    Feb 21, 2019
    Posts:
    21
    upload_2019-6-27_16-53-50.png

    These rocks are all formed by various brushes, mostly Carpet Brushes. Carpet is good but it cannot handle every possible situation I need, so in situations like this I need to manually fix the tiles.

    How do I draw in tiles without the auto tiling automatically changing everything to account for the new tiles I drew? I want to put in the correct tile in the correct place at this moment, I don't want to add another tile layer over top of everything just specifically for making corrections, I want it to be on the same tilemap layer as the auto tiling brush.

    I know ive seen people say you should set the brush to auto tile with various options, but that is extremely chaotic and unpredictable how my brushes start tiling with things I absolutely dont want them to tile with, but the same exact tile in another place I might DO want it to tile with.

    What is the expected use case or how am I supposed to use this tool correctly to put in per single tile corrections to problems caused by my brushes?
     
  48. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,091
    In this case the only way is creating a custom brush with custom rules.
    There two brushes that could help you:
    The Brrush 47, included in the asset and the experimental TerrainBrush that I have attached to this post.

    Try to see if those brushes fits your needs. Otherwise you could need to modify the carpet brush to have those cases into account. In that case, let me know and I will lead you how to achieve that.
     

    Attached Files:

  49. ryanzec

    ryanzec

    Joined:
    Jun 10, 2008
    Posts:
    659
    @CreativeSpore So I have started to use the tilemap editor a lot more recently and things are really not working well with tilemaps in prefabs. Now when I am editing a map in prefab mode, I get this error pretty frequently:

    ste tile editor.png

    It is reference this code in STETilemap (lines 1130 - 1138), specifically the DestroyImmediate(chunk.gameObject) call:

    Code (CSharp):
    1.  
    2. #if UNITY_EDITOR
    3.         if (IsUndoEnabled)
    4.         {
    5.             Undo.DestroyObjectImmediate(chunk.gameObject);
    6.         }
    7.         else
    8.         {
    9.             DestroyImmediate(chunk.gameObject);
    10.         }
    11. #else
    12.  
    This happens whether I am editing the tilemap in prefab mode of in the scene, it just seems to happen when the tilemap is in a prefab and once this error show, I pretty much can't modify the map. If I unpack the prefab, the editing the map goes back to normal (along with the performance issue I mentioned previously returning to normal.

    This is with the latest version of unity (2019.1.8f1) and Super Tilemap Editor (1.6.2).

    This is getting to the point where I not going to be able to use Super Tilemap Editor as having tilemaps in prefabs is going to be pretty critical for me. I could using scenes instead of prefabs but for my game that would require quite a bit more work where I would probably just investigation Unity's tilemap system instead of using scenes.
     
  50. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,091
    I couldn't replicate those errors. I am not sure if there is something wrong with the prefab or I missed the use case to replicate the error.
    I tried to replicate the error in Unity 2019.1.8f1 creating a prefab from PixelPlatformDemo scene TIlemaps object.
    Then I tried to force the error by adding a tile far enough to create a chunks then deleting it to force the destruction of the chunk.
    I tried this from the prefab edit menu by double clicking the prefab and from a scene by clicking the '>' icon.

    Could you try to create a prefab from a simple tilemap and see if it happens also with a new prefab?
    Also, if you could send me a test project or just a prefab so I can reproduce it. You can paint black the tileset textures, I only need to replicate the error by editing the tilemap.