How to create random, animated tiles, and non-animated tiles? 2D Extras

Hi,

I have been learning to use the 2D Extras from GitHub with the Unity 2D tilemap system. A lot of it works great, but I’m having trouble figuring out how to save my time with the water.

In my game, the water is made of up plain blue tiles, and 4 different variations of animated, like below:

I want a way to be able to fill my screen with water, like above, but have it so that it randomly places the water tiles, weighted with probabilities. And I want the plain blue, static water to be the most common, and the 4 different animated tiles to randomly appear with different frequencies.

I can see numerous ways to randomly place the water tiles if they are just sprites, but having trouble to see a way to combine animated tiles, or prefabs, and random probabilities.

Is there a way to randomly place animated tiles, or prefabs, and manually give weight to each one? A variation of the Weighted Random tile where you can place other tiles or game objects would be ideal but that doesn’t seem to be a feature.

As far as I can see, there’s no way to randomly place animated tiles, only sprites and prefabs. And from what I can see, with the Random Prefab Brush, you can’t give probability weights to individual prefabs, it’s just a general randomness factor, which isn’t what I want.

At the moment it seems my only solution is to manually place each animated water tile. Any better ideas?

If this isn’t a feature currently, it should be.

Thanks.

any reason why you cant use SetTile()?

I’m not sure what you mean by that. Use that where? I was looking to see if there were any Tiles / Brushes that already do the functionality I want.

In any case, after a very long day, I believe I’ve created a new custom brush script that does everything I want. I would have preferred this was a feature already but oh well. I’m still tweaking it and I’ll share a code sample later.

And done. I’ve written up a little “How to” guide for how to set it up, and given the code.

Basically, I wrote over the “Prefab Random Brush” because I didn’t find it very useful, and instead made a new brush that will paint random tiles, based on a probability assigned to each tile. You can use any kind of tile in any combination with each other other, rule and animates tiles, normal tiles, etc.

I also added functionality so that it would work with the fill tool.

Here’s quick previews: