Game Development Reference
In-Depth Information
4.7 Breakable objects
In the previous section, we learned how to construct a building using destructible building
blocks. However, for smaller destroyable (or breakable) objects, we need a more appro-
priate approach. For objects like boxes that player break in order to get items, or glass
windows that collapse when shot and turn into small pieces; we need a different method
of destruction. This method can be used for one- way destruction, in which the destroyed
object cannot be constructed again. The idea is to remove the original object from the scene,
and instantly create a collection of pieces that are smaller in size and have the same texture
of the original object. These pieces can be made using prefabs as we are going to see. Con-
sider the building we constructed in the previous section, what about adding some glass
windows? First of all, we need a prefab for the window, which must be breakable (and de-
structible as well). The glass block might look like Listing 47.
Illustration 74: Glass block to be used as breakable window
Search WWH ::




Custom Search