#Not able to blast tiles in bomb blast
1 messages · Page 1 of 1 (latest)
I have no clue how this has anything to do with coroutines... anyways how is the map defined? Is it a tilemap?
No, i have placed individual floor to make complete ground. Actually i used Raycast to identify collider and demolish in the region
CODE
private IEnumerator FloorExplosion(Vector3 direction)
{
for (int i = 0; i < 2; i++)
{
RaycastHit hit;
Physics.Raycast(transform.position + new Vector3(0,1f,0), 2*direction, out hit,i, Wall);
if (!hit.collider)
{
Debug.Log("Safe");
}
else
{
floors = GameObject.FindGameObjectsWithTag("Destructable") ;
foreach(var floor in floors)
{
floorInstance.DestroyFloor(floor);
}
}
yield return new WaitForSeconds(.05f);
}
}
are you using a tilemap?
if you're using a tile map you need a reference to the grid and the tilemap
get the bomb position and use the grid to convert it to a cell position
use that cell position on the tilemap to set the tile on the position to the destroyed tile, or set it to null if you want to delete it via the function m_Tilemap.SetTile('destroyed tile/null')
and do the same thing for all the tiles around it but adding the index to the bomb cell position like
Vector3Int top = cellPosition.y + 1;
Vector3Int bottom = cellPosition.y - 1;
Vector3Int topLeft = cellPosition + new Vector3Int(1, 1, 0);
etc...
okay, i have never used tilemap, can you tell me more on it
You can watch the brackeys video on it, it covers all the needed information, except the use in runtime which is what I explained here