Water Tiles Random vs. Animated

For some of the water tiles there are more than one tile for the position. I had initially set these up as random.
When animating those, I had to change from random to animated.

Is there another way to deal with this to make a tile rule where a tile can be random between two animated options?

2 Likes

I had though the same … :grinning_face_with_smiling_eyes:

As far as I’m aware, there is no simple way to do this. With the basic rule tiles it’s either; Single, Random, or Animation.

If you’re so inclined, you could probably write you’re own script that inherits from RuleTile and then extends the behaviour to handle the animation of randomly selected tiles.
I’ve not actually tried implementing this functionality but I imagine that it’s probably a bit involved and would currently be out of scope for the course.

However, I will speak to Stephen and get his thoughts.

4 Likes

For some reason my thread on this was auto-closed with setting a “solved” on the last posting, which is definitely not true.

It does seem to be a bit of an omission that you can’t have random tile placement once you also want to have some sort of animation. I can well imagine having a tile setup to be for one side and having animation tile(s) defined as we did in this lesson, and then another one which has its own animation tile(s). The question would be, if I add two tiles with the same rule conditions, could that even work and if so, with what result?

1 Like

I totally agree that there should be an option for a random animation pair in the rule tiles and hopefully Unity will get around to adding this feature at some point.

The only alternative to coding the logic yourself would be to manually place any additional animated tiles manually on a new layer. Note that rule tiles only look for instances of themselves so, if you place a different tile on the same layer, it will be ignored by your rules and you’ll end up with corner pieces on either side.

Unfortunately, you can’t just add a second rule with the same conditions. Rules are executed from top to bottom, so the second one would always be ignored. This is why setting up rule tiles can be such a headache - it’s very easy to get the ordering wrong!

To some extent it makes you wonder why there’s not one larger layout for the rule tiles where you just dropped the single texture images into the matching spots and where done with it, but then there is also that center setting which has some flipping or rotating(?) that Stephen mentioned at one point like “you could do something with this but for simplicity let’s skip over it and just add some more rule slots” (or something similar… I wonder if there will be some getting back to this detail at some later point?)

Well, if you stacked several tile maps, they wouldn’t be randomized but I suppose the
“random” part only applies for placing the tile (or it updating when the neighbours change and trigger a re-evaluation of its rules), anyway…

So if you setup another map layer for having variations, I guess you would just have singular tiles for the other versions that would overlay a single spot and have no neighbours defined at all, and on the “base” layer you might have one for the spot that would have a blank texture but stand in for its neighbours?

And I suppose with your “randomization layer” you could have several rule tiles for each group of variations all on one tilemap layer, so you wouldn’t start stacking like a hundred of them?

I would love to see a showcase scene as a unitypackage one could add to the project…

I was looking through the TileMap documentation and came across this:

https://docs.unity3d.com/Packages/com.unity.2d.tilemap.extras@4.0/manual/AnimatedTile.html

So it would seem, instead of defining the animation within the Rule Tile settings, one would actually setup a bunch of pre-defined Animated Tiles and then add these into the Rule Tile for a random selection…
Seems like quite a bit of work to setup, but might be the way to go…

@garypettie What do you think?

When we were setting up the tile rule, weren’t we using sprites not tiles?

Yes, but I think it would be possible to use pre-defined animation tiles instead so you could have several (one for each variation of the ponds’ shore) and then have them randomly selected from the rule tiles’ settings.

1 Like

It’s definitely a good idea but I don’t think it will work (note: I haven’t actually tested it).
As far as I know, the rule tiles will only act on sprites and not other tiles, so you can’t just create an anim tile and then plug that directly into the rule tile.

if you do get it working, let me know. I still think you’d need to do some custom scripting though.

Well, I guess the alternative approach would be to get my attempt for a shader working the way I want. Then one could simply have standard randomized tiles and do the water waves as part of the shader…

Unfortunately so far I haven’t been successful in doing some sort of “green-screen” (or rather “blue-screen” in this case since the water surface of the tiles is blue) going…

I did get the “blue screen” working for my shader, but apart from just changing the whole colour (albedo or emission level), my attempts at some sort of “wave effect” have been less successful. If I tried to make it more pixely similar to the rest of the game, the tile structure became extremely apparent. I could scale down the water pixels to make this disappear but then it didn’t really fit in with the pixel style of the other sprites…

At some later time I might get back to this and probably see if it’s possible to use a sub-graph as some kind of property so one could plugin different kinds of changes using the same “blue screen” shader wrapped around. Otherwise I would have to see how one could turn the blue-screen into a sub-graph but doesn’t appear to me to be a good approach…

Privacy & Terms