So I believe I have added the colliders correctly but I can’t seem to view or interact with my colliders on my isometric tilemap.
Here is the steps I followed:
- I added a custom physics shape to my sprite.
- My isometric rule tile’s default collider is set to sprite
- I added a TilemapCollider 2D component to my tilemap.
- When the player clicks (in building mode) it spawns a tile at said position then refreshes the tilemap’s collider.
myTilemap.SetTile(tilePos, selectedObject.Tile);
Debug.Log(myTilemap.GetComponent<TilemapCollider2D>().hasTilemapChanges); //returns true
myTilemap.GetComponent<TilemapCollider2D>().ProcessTilemapChanges();
- When the player then tries to click (in building selection mode) on the newly created tile.
RaycastHit hit;
var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(ray, out hit))
{
Debug.DrawRay(ray.origin, ray.direction, Color.red);
Debug.Log(hit.collider.GetComponent<Sprite>());
}
else
{
Debug.Log("No hit"); //returns this every time
}
I had hoped by running Window>Analysis>Physics Debugger I could see the collider shapes in play mode but I cannot see anything.
If someone could point me to the step I’m missing it would be greatly appreciated.