There seems to be a particular number of bullets(damage) that each tile can take before being destroyed. There also is a blast radius of the bomb that destroys all the tiles in its’ vicinity. What aspects of Unity do I need to look into, to achieve such destructible and crumbling effects ?
You declare a 2-dimensional array which holds the integrity values of each block.
var world : float[,] = new float[worldSizeX, worldSizeY];
If a tile gets damages, you just decrease the float value at the coordinates.
world[2,6] -= damage;
if(world[2,6] <= 0.0f) {
//some kind of destruction effect?
}
Getting all tiles in a radius should be easy, just use a nested loop with x - 1 to x + 1 and so on.
I think you should make script and attach to tiles that holds number of times you shooted at that tile. Something like:
tileLogic.js
var tileHealth : int;
function Start() {
tileHealth = 3;
}
function Update () {
if(tileHealth == 0){
Destroy (gameObject);
}
}
function OnCollisionEnter2D(coll: Collision2D) {
if (coll.gameObject.tag == "Bullet")
tileHealth--;
if (coll.gameObject.tag == "Bullet")
tileHealth-=3;
}
In this case you should have colliders2d on tile, bullet and bomb (size of the radius).