Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RuleTile with sibling layer tilemaps? z-axis siblings? #374

Open
64n35h4 opened this issue Aug 17, 2023 · 1 comment
Open

RuleTile with sibling layer tilemaps? z-axis siblings? #374

64n35h4 opened this issue Aug 17, 2023 · 1 comment

Comments

@64n35h4
Copy link

64n35h4 commented Aug 17, 2023

Hi

I'm not sure how to pharse the headline.. but I'm trying to use the module (RuleTile in specific) to create a tile for creating edge tiles (over water/lava etc..)

I got a grid with several layers
I want to create 2 layers (assuming layer Ground and layer Edge)
Layer Ground would be grass with patches of water (attached a picture)
Layer Edge would be just the edge tiles on the border of the water patches
As seen in the picture, some of the tiles work with rotation etc, because there's other this/not-this/sametype in the neightborhood (assuming they're on the same tilemap)

I was wondering how can I check for neightbors on the z-axis? tried to create a public tilemap property on the Rule and passing the relavent tilemap, but was ineffective.
image
image
(The RED "X" are null in the Edge layer, but i'd like to "check" the type of the tile below/above/or on a layer by name?)
image

Would appriciate any direction.
Thank you.

@ChuanXin-Unity
Copy link
Collaborator

ChuanXin-Unity commented Aug 23, 2023

Hi, are the Ground and Edge layers in the same Tilemap but have different Z coordinates (eg. Edge is Z=1 and Ground is Z=0)? If you create a CustomRuleTile, you could query for Tiles in the different layers by changing the Z position.

If they are on different Tilemap GameObjects but share the same parent Grid, you could query for the different layers in GetTileData using the ITilemap to get the actual Tilemap:

public override void GetTileData(Vector3Int position, ITilemap tilemap, ref TileData tileData) {
var actualTilemap = tilemap.GetComponent();
var layoutGrid = actualTilemap.layoutGrid;
var tilemaps = layoutGrid.GetComponentsInChildren(); // This will get all the Tilemap layers
...

Hope this helps! Let us know if you need more information!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants