Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

[Feature Request] Random tool via highlighted tiles, not a clunky Random Brush

Discussion in '2D Experimental Preview' started by AssembledVS, Jan 5, 2019.

  1. AssembledVS

    AssembledVS

    Joined:
    Feb 23, 2014
    Posts:
    248
    We have a real need for a "random" tool instead of the Random Brush that Unity currently has. A visual mockup is attached to this post. Notice that this tool is one of the tools listed on top of the Tile Palette window and not a Grid Brush.

    The tool should allow you to select your desired tiles directly on the tileset palette, much like the select, paint, box, and flood fill tools allow you to. From this selection, a single randomized tile is given. Whenever the tile is placed within the scene, or even better, whenever a new grid cell is hovered over in the scene, this randomized tile is re-rolled, allowing the user to quickly get a new randomized tile if the current one is not ideal. Perhaps this tool can also have variations like Random Flood Fill and Random Box for randomizing large swathes of the tilemap.

    The current workflow is simply too convoluted and difficult. I see two main problems:

    1. Needing a different Random Brush for every group of tiles that we wish to randomize. I would need a dozen or two per tile palette, and if I wish to remove or add certain tiles from this group, I have to go back and edit the brush.

    2. The difficulty in selecting the actual sprite assets. Most tiles come from spritesheets, which are organized the way my example is organized. Using my selection as an example, if I browse to the tile sprite assets, they would be disordered, as my group of selected tiles are in the middle of a bunch of other tiles (since tiles are cut row by row from left to right, even though they are organized to be visually understandable via groups of tiles the way my spritesheet/tileset is set up).

    Though this is less important, I think that being able to clarify the tile size, and getting a random tile group selection based on that size, should also be considered. For example, in my spritesheet, the tiles adjacent to the left are sized 2x2. If they are selected and this random tool is implemented, I would get a random 1x1 selection, which would jumble the placement of 2x2 tiles that are drawn to be 2x2. So ideally, after making this tile selection, you can clarify tile size 2x2 and the tool would break up the selection into 2x2 tile groups that are randomly selected instead of 1x1 tiles. Otherwise, these tiles would have to be placed on a different spritesheet or tile palette and would have to use a whole different Grid with a 2x2 cell size, even though they are very closely related to the rest of tiles.

    Another thing to consider would be random tile weights, but I'm not too sure how that would be implemented in this context.

    Is this something that is possible or is being worked on?

    If anyone wishes to vote on this idea, I have uploaded it to Unity Feedback:
    https://feedback.unity3d.com/sugges...a-highlighted-tiles-not-a-clunky-random-brush
     

    Attached Files:

    2dchaos likes this.
  2. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    1,068
    Having this seems possible definitely.

    As an example of 1, I have updated the RandomBrush on 2d-extras so that you can pick the Tiles which you would like to be in your random set from the Tile Palette using the Pick mode, by toggling picking functionality in the Random Brush Inspector.
     
    AssembledVS and 2dchaos like this.
  3. AssembledVS

    AssembledVS

    Joined:
    Feb 23, 2014
    Posts:
    248
    I just tried the brush and this is EXACTLY what we need, thank you! Such a simpler and more intuitive workflow! This is great. You actually fixed #1 and #2 with this brush, as we don't need a separate random brush for each group of tiles we wish to randomize and we don't have to scour through our assets to choose tiles but instead do it directly via the Tile Palette. This should be part of the main package, to be honest - it's just that useful.

    I feel like "clarifying" the size is the other thing I'd really want so that we'd be able to randomize between tiles that are combinations of tiles (like the 2x2 ones on the left) but are on the same Tile Palette and Tilemap.

    Looking forward to seeing the final implementation of the Random Brush and being able to sort our Active Tilemap List.
     
  4. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    1,068
    Just to clarify, does this mean that you would like to be able to randomly pick and paint between sets of 2 x 2 Tiles (or n x m), and maintain their relative order between them?
     
  5. AssembledVS

    AssembledVS

    Joined:
    Feb 23, 2014
    Posts:
    248
    I think so, yes. I am including another mockup to show what I mean.

    My Grid game object has a cell size of 1x1, which in my case, is 8 pixels x 8 pixels. My tilesets are all composed of 1x1 tiles to be used by the 1x1 Grid game object, but some of those tiles are combined to create larger tile "chunks." In my image, these chunks are 16x16 pixels, or 2x2.

    I cannot use the Random Brush that you created to highlight those 2x2 chunks for random tile placement because that would result in random 1x1 pieces of the 2x2 chunks getting picked. So if there's, say, a rock that's 2x2, I cannot place these random rocks in my scene, as only pieces of those rocks would be picked. If we can clarify a tile size of 2x2 (or n x m), then the brush would automatically select 2x2 chunks of the highlighted portion of a tileset.

    The alternative right now is to have a new Grid with 2x2 cell sizes, and another Grid for any other non 1x1 cell size, and a separate Tileset/Tile Palette for each. As you can see, my tiles relate directly to each other, meaning that a separate Grid and tileset doesn't make much sense. They're all part of the same tileset; some parts just form larger chunks.
     

    Attached Files:

  6. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    1,068
    Specifying groups of Tiles and randomizing between these sets is possible with custom brush scripting. The Random Brush can be updated with that functionality.
     
  7. AssembledVS

    AssembledVS

    Joined:
    Feb 23, 2014
    Posts:
    248
    Thank you, that sounds promising. Can you point us in the right direction for something like this? Would we be able to specify these tiles with a selection box like now?
     
  8. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    1,068
    I made an update of Random Brush here. You are able to specify the size of the set of Tiles and the Brush will randomise between these sets. Creating the set selection is done through the Pick tool. Let's see if that works out?
     
    AssembledVS likes this.
  9. AssembledVS

    AssembledVS

    Joined:
    Feb 23, 2014
    Posts:
    248
    This is perfect, thank you @ChuanXin ! This is such a better workflow. What a timesaver. I'm really impressed.

    By deselecting "Pick Random Tiles" after picking the set, we can now create a new selection with the brush tool (doesn't matter if it's empty) and use that selection as a new brush size to place our randomized tiles (instead of placing them one by one). Since we cannot seem to use the box or flood fill tools with the Random Brush, this works well enough to paint large swathes of the grid.
     
    Last edited: Jan 21, 2019
  10. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    1,068
    Updating the box tool would be possible, flood fill will be trickier. If you have any more ideas for this, do post it here or on 2d-extras!
     
  11. AssembledVS

    AssembledVS

    Joined:
    Feb 23, 2014
    Posts:
    248
    I wish that I understood the inner workings of the Tilemap API to help a bit further with this. Truth is, I know next to nothing about the tools and didn't even think that it was possible to recreate the Random Brush in the way that you have (since none of the Asset Store tilemap assets had this functionality, I thought that this was a Unity limitation or something). But if I see a problem with the workflow like I saw with the Random Brush, I will be sure to post ideas about how I think it should work.

    I think that this Random Brush addition should be stickied or something, or maybe even included as part of the next Unity build (not sure if 2D Extras/Random Brush comes with the regular Unity package). Most people don't check this forum or know about the 2D Extras.
     
  12. AssembledVS

    AssembledVS

    Joined:
    Feb 23, 2014
    Posts:
    248
    @ChuanXin, I have two more things to address, one a feature, and the other a bug with the current Random Brush implementation.

    The feature - right now, we cannot select tiles for random selection that are not a single rectangle in size - e.g., we cannot Ctrl+Click (or whatever shortcut) to add extra tiles by dragging an additional selection box. This means that the only tiles that can be selected for random placement at any one time are the ones that happen to fit into exactly one rectangular selection box. I am attaching a mockup of the expected behavior.

    The bug - to reproduce it:
    01. Select the Brush tool.
    02. Select the Random Brush.
    03. Check "Select Random Tiles."
    04. Make a selection of several tiles.
    05. Paint with it and notice that the brush size is a single tile output from the selection box, which is expected.
    06. Uncheck "Select Random Tiles."
    07. Make a selection of several tiles or empty tiles.
    08. Paint with it and notice that the brush size is the size of this new selection. Not sure if this is expected, but this behavior allows us to create larger brushes (not single-tile-sized) to paint large swathes of the grid with a randomized selection. So this is good.
    09. Try to get back to using a one-tile sized brush by checking "Select Random Tiles" and making a new selection of tiles.
    10. Notice that the old selection's brush size is preserved and not a single-tile brush size.

    This doesn't always happen but it happens enough to make the bug obvious. The process will have to be repeated several times (checking/unchecking, making new selections) for it to start working again, or a new brush would have to be selected and then you'd have to go back to the old brush to make it work again.
     

    Attached Files:

  13. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    1,068
    Sorry, for the late reply, will check this out!
     
  14. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    1,068
    AssembledVS likes this.
  15. AssembledVS

    AssembledVS

    Joined:
    Feb 23, 2014
    Posts:
    248
    Thank you, @ChuanXin. This is exactly the functionality that I'm looking for.

    What I like about this specific implementation is that we can choose the same sets of tiles multiple times, which in effect acts as a way of adding weights to those tiles. For example, if we pick 4 tiles, and one of those tiles is picked/added 3 times and the others are picked/added once, we increase the frequency of that tile popping up.

    I can't think of much else to do with the Random Brush, except maybe somehow making it work with the Rectangle and Flood Fill tools.

    I think it makes a lot of sense to include these extras as part of the main Unity install, or at least make it be part of the Package Manager so that others may find it more easily.

    Thanks for all of your help.
     
    Last edited: Feb 23, 2019