UNITY: Hanging Debris


In one of my games, I had destructible buildings, which would break into debris chunks. However the object full of debris chunks would be kinematic and not affected by physics at first. As each of these objects received a DoCollision() message, they were then knocked and would be affected by gravity/physics. The debris would then ask its neighbours and would query them to see if it either had no linking neighbours at all, or if the support below the debris had been removed to a certain threshold and would then collapse more of the building. The parent object that would swap the model out for the debris would create the initial neighbour links and surface information.

This gave buildings a very realistic crumbling effect as you smashed through them.


Link to Pastebin of source can be found here -> http://pastebin.com/PyKJJKk4.

UNITY: Particle System Auto Destroy

A small Unity component that will help clean up gameobjects that have particle systems. This is useful for anything that will automatically spawn particle objects and can be included in prefabs or attached while a particle system currently existing.


Link to Pastebin of code can be found here -> http://pastebin.com/zmpnq9Wx.