2d-extras icon indicating copy to clipboard operation
2d-extras copied to clipboard

Rule Tile interaction with other tiles

Open DVonk opened this issue 4 years ago • 5 comments

Hi, I'm trying to use rule tiles to draw some ledges. It works, but the interaction with other tiles seems really hard to grasp. I've made a rule tile for the ground and one for ledges. Now I want to add stairs. But it looks like this:

grafik

  • The left is what happens when I draw on the same layer and interupt the rule tile.
  • The right is how it should look like. I've drawn the stairs on a layer above the ledge, but now the collisions don't work properly, since Unity is still using the rule tile's collider: grafik

How is this meant to be done? I can't delete individual rule tiles as I'll get the left version. But I can't draw on top of the rule tiles as their collider still exists.

I was thinking about making a second rule tile for the stairs, but it has to interact with the ledge rule tile for this to work properly. Is there an easy solution to this or can this be done with a custom rule script?

DVonk avatar Nov 24 '20 00:11 DVonk

You could use a custom Rule Tile for the stairs which also interacts with the ledge Rule Tile.

There is an example here: https://github.com/Unity-Technologies/2d-techdemos/tree/master/Assets/Tilemap/Rule%20Tiles/Rule%20Override%20Tile

The ExampleSiblingRuleTile defines a normal clothesline and a clothesline with clothes as Siblings, so that they can interact with each other. The clothesline with clothes overrides the standard clothesline with Sprites with clothes with the same Rules. You could use the same for the stairs, including changing the collider type as well.

Let us know if that works out for you!

ChuanXin-Unity avatar Nov 25 '20 01:11 ChuanXin-Unity

Seems to work pretty well, thank you. I actually wish that this kind of functionality was built into the rule tiles. It seems that whenever I use Tilemap this exact problem comes up. It's pretty rare that I don't want to put in some other tile that "breaks" the rule tiles.

DVonk avatar Nov 26 '20 22:11 DVonk

Thanks for the feedback! It looks like this comes up pretty often, so we will try to consider this addition.

On Fri, 27 Nov 2020, 06:15 Daniel Vonk, [email protected] wrote:

Seems to work pretty well, thank you. I actually wish that this kind of functionality was built into the rule tiles. It seems that whenever I use Tilemap this exact problem comes up. It's pretty rare that I don't want to put in some other tile that "breaks" the rule tiles.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Unity-Technologies/2d-extras/issues/249#issuecomment-734494312, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHA3TEUVOO2DXGXWJPYRJ5TSR3HQZANCNFSM4UAFGLOA .

ChuanXin-Unity avatar Nov 27 '20 01:11 ChuanXin-Unity

I don't recommend it to be provide by the repo... it has too much freedom. But maybe we can provide multiple custom rule tile template as suggested implementation for example.

johnsoncodehk avatar Nov 28 '20 20:11 johnsoncodehk

I guess it would be useful if it was included as a Sample in the package which can be installed in the Package Manager, although adding Script files there require a bit of management for each different version of the package.

ChuanXin-Unity avatar Nov 30 '20 01:11 ChuanXin-Unity