So for an upcoming prototype that I'm working on we are playing around a lot with the physics in Unity. One of the assets we need to have is a door that can explode when an object hits it, giving the player a certain amount of satisfaction and excitement. Once I obtained this asset, I dumped it into Unity and immediately began plying around with it. I had a basic idea of how it would work. When the objects that the player can throw around collide with the door, the door will spawn in the broken variant of the door and disable itself in order to allow for the pieces to scatter around. These lines of code were simple to put together, the alteration of the prefab itself was the p
After some tinkering we found that adding force to each of the shards to have all of the shards fly out in a destructive manner rather than replacing the door and falling in place is much more satisfying to see and acknowledge that you have done. Below are the results of all of these aspects coming together. 10/10.
The script for the function above can be found in the project repository here.