Skip to content

Instantly share code, notes, and snippets.

@Plnda
Created August 12, 2020 09:08
Show Gist options
  • Save Plnda/3455a450f512f64cd2c48f41717c7ee2 to your computer and use it in GitHub Desktop.
Save Plnda/3455a450f512f64cd2c48f41717c7ee2 to your computer and use it in GitHub Desktop.
Tilecheck
public string GetGroundTypeFromPosition(Vector3 position)
{
if(sortedLayers == null)
{
sortedLayers = layers
.ToArray()
.OrderByDescending(x => x.GetComponent<TilemapRenderer>().sortingOrder);
}
foreach(var tileMap in sortedLayers)
{
var tile = tileMap.GetTile(Vector3Int.RoundToInt(position));
if(tile != null)
{
return tileMap.name;
}
}
return "Ground";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment