Right now I’m making a top down game. I’m using a custom rule tile for the walls because I need to check if the neighboring tile is a ground tile since that would affect where the light is coming from. For example if a wall tile only has a ground tile below it but not above it it should place this tile:
But if the wall tile has ground tiles above it and below it it would be:
Here is the code I’m using:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Tilemaps;
[CreateAssetMenu]
public class WallRuleTileScript : RuleTile<WallRuleTileScript.Neighbor> {
public TileBase ground;
public class Neighbor : RuleTile.TilingRule.Neighbor {
public const int Ground = 3;
public const int NotGround = 4;
}
public override bool RuleMatch(int neighbor, TileBase tile) {
switch (neighbor) {
case Neighbor.This: return tile == this;
case Neighbor.NotThis: return tile != this;
case Neighbor.Ground: return tile == ground;
case Neighbor.NotGround: return tile != ground;
}
return base.RuleMatch(neighbor, tile);
}
}
So right now my problem is that for this to work I need both the ground and the walls to be in the same tilemap, however, I need to have them in separate tilemaps so I can have them in separate layers. How could I make the wall tiles check the other tilemap for the ground tiles?