I am currently trying to make a Tetris game using Raycasts and Colliders, since I dislike and don´t understand at all the use of Arrays for it (and also maybe because i´m kind of in a hurry x_X), but I´m stuck with a problem.
The Tetrominos are composed of 4 Child Blocks, each of them with their own script checking with Raycasts the moment the parent must stop. When that happens, the Parent detaches all the Child Blocks with transform.DetachChildren and is destroyed with Destroy(gameObject). It also changes the layer from Movable Pieces to Set Pieces.
My problem is that after this happens, the blocks “Cease to Exist” even though they are visible and checkable in the Editor with the inspector. Using Debug.Log with the collider.bounds.size of each block I found out that the values were set to (0,0,0) after the transform.DetachChildren and Destroy(gameObject) in the Tetromino Parent.
Is this supposed to work like that? How do I Fix the collider size (collider.bounds is Read-Only)?
I tried resetting the BoxCollider size of each block in the update but they still don´t collide with any RayCasts and even the values in the Inspector seem right. But while the Size in the Inspector shows 1, collider.bounds.size is (0,0,0). The Collider sizes in the Editor seem right as well. However, if I pause the game and modify the size of any collider in any way, it resets back to 1 (because of the code in which I reset the size) and the collider.bounds.size value changes to what it really is (1,1,1). It even collides as it should right after I do that =S.