Introduction:
I spent time focusing a lot of effort on learning destruction and fracturing meshes. I like how it turned out.
Destruction and Fracturing:
I spent more time on this than anticipated. I actually completed the tutorial the first day, except for the last ‘challenge’. I made several destructible meshes and learned about the fracture tool in Unreal Engine. What got me stuck for an extra day was the challenge of adding something to the game for the players to destroy.
I had previously made explosive barrels, so I figured I’d add some pillars or structure that would fracture and crumble when the barrel exploded nearby.
First I had the problem of the pillar falling over at the start of the game and then just fracturing when it hit the ground. I learned about the ‘start awake’ property, which if disabled would prevent collision/physics on the object when the games started. Simply disabling ‘start awake’ on the pillar itself allowed it to stand without falling when the game started.
Next was to figure out how to turn physics back on when it took damage. My first thought was to use the ‘event AnyDamage’ and connect that to the ‘set simulate physics’ as enabled node. Technically this worked, physics was being enabled, but the pillar was still not reacting to the barrel explosion.
Next I tried adding an ‘apply radial impulse’ node right before the ‘apply radial damage’ node on the barrel itself. I used the barrel’s world location as the origin. And yet still the pillar didn’t react to the barrel explosion.
After some debugging using print strings I discovered that indeed the pillar was receiving damage, but wasn’t receiving the impulse, however neither was causing the pillar to actually react to the damage being done.
My solution was to first move the ‘set physics simulation’ node to the ‘event BeginPlay’ with a 3 second delay. This means it always has physics on after the game starts no matter if it’s taken damage or not.
Secondly I added a ‘apply radial impulse’ node to the ‘event AnyDamage’ on the pillar itself. I chose the pillar’s geometry component for the radial impulse component and the origin came from the ‘event anydamage’ ‘damage causer’ world location. Finally I took the ‘damage’ paremeter from ‘event anydamage’ node and attached it to the ‘strength’ paremeter on the ‘apply radial impulse’ node.
So now the pillar would apply a directional impulse based on where the damage came from and it’s strength is based on whatever caused the damage.
Lastly, to make it look cool, I enabled ‘Apply Strain’ on the ‘apply radial impulse’ node. With this disabled the pillar would simply fall over when it took damage. With that ‘enabled’ it now reacts/fractures more realistically depending on the location and strength of the damage done to it (in this case, an exploding barrel).
The results are quite nice!
Conclusion:
As I mentioned before, understanding detailed damage models is one of my main goals in Unreal Engine and something I intend to focus on in games I create using my own ideas. This is partly why I took the effort to at least learn this much about destruction and fracturing instead of skipping and moving on. I still have a lot to learn!