This is a big week for me. I get to check of a buck-list item! I've always wanted to make a scifi game where ships weapons can literally split other ships in 1/2. It was an indirect path to get there, but we are now there!
Initially, I thought I would be able to use something similar to fruit-ninja object splitting for ships. It sounded good in theory and it took me a couple days to get implemented but I HATED IT. If the bullet/weapon vector hit the ship where it made since to split it it could look ok, but I didn't think through the other 90% of the time like this case:
Of course that slice is before adding damage decals, venting atmosphere etc, but there are obvious problems. See the little bits floating? In slicing there are only two resulting objects but really it would need 6 in the test slice above. The big issue was even if I did the work to alpha test per pixel and make all the little objects and colliders, it wouldn't look feel right to slice like that.
So.... back to the drawing board. We always wanted to have hitpoints attached to main systems for failure such as engine, turning thrusters, main and secondary weapons. Now is a great time to integrate that plan into the damage system. Instead of just putting a decal on top of that section of the ship to indicate damage, how about just blowing it off the ship? Hmmm now we're talking!
Step1, I added damage decals and atmosphere venting for when something is just damaged but not destroyed. Note that each ship will have it's own damage decal and venting fx to fit the design/race. I was very pleased with the result.
Something that was unexpected w/ the lighting system I put on the ships was that the decals do not honor the ship's normal and heightmaps. I thought that may be a problem until I saw the effect. It has more of an effect that a chunk is missing from the ship which was an unexpected bonus. I love when stuff works out like that.
Happy with that result, I set out to make ship parts destructible. For this, instead of trying to work out an 'any-angle-slicer' I decided to do it in a way that would look a lot better. First, I revisited each ship's graphic and split it into each system and assembled back to a full ship. Then each system/part had it's own collider:
Now to plan how each part will break away when destroyed. I decided on a handful of pre-planned weak points where the systems would fail and look cool/correct. Granted, this adds some extra work per ship and we have 25+ ships, but it's worth it. Then I setup fx decals on both sides of the breakaway and each side would have it's own atmosphere venting particle system. AWESOME now I can make something full fail! So satisfying:
For the Krex, the front wing like parts also house the turning thrusters. So when that part goes, so much for the player's ability to turn right! Next up, MAJOR failure :)
I must of lost 1/2 a day in pure bliss splitting the krex over and over :) Notice that the player can still control what remains. He had engines and a single of it's three canons. I hadn't finished w the code... it shouldn't have had turning in that example.
Next... let's debug it all and setup all parts to 1 hitpoint. I added some physics code so that destroyed parts can bump other parts and do damage as well:
One thing still caught my eye though. When something is destroyed it needs an explosion. It will also make the damage decal a lot cooler so it doesn't just 'pop' into the scene. It was time to implement that and then hook it all up. The Salrith was the perfect ship to test it. In the game the Salrith race is ancient and advanced. One of their weapons is pretty impressive ramming. So here goes.... how does it all come together? Drum roll.......
And THAT is how you check something off your bucket list -- IN STYLE!