Teardown

Teardown

Ascended Sword Master
Geneosis  [developer] 1 Nov, 2024 @ 10:39am
Dev notes
Because I know you love wall of texts, I'll do my best with this one as well ;)
Where to even begin... I think this mod was mainly inspired by the announcement of 1.6.0, as I thought about third person becoming a think, I was imagining stuff that could be nice to do with only a few character animations instead of an actual weapon to hold. And obviously, what a better weapon to control remotely than a plain old sword :p (or I may just have been watching way too much chinese animes recently...)
Regardless, this seemed like a fun new way to destroy stuff in Teardown, so I started thinking about a lot of cool ways to store swords around your character as well as ways to attack with them obviously.
But before I could start, I would have to find an actual sword model (as I am way too lazy and way too bad at modeling to come up with one myself...), so I did browse a few asset stores and ended up finding ch33s3's sword which looked just about right to fit with what I had in mind with this mod :)
Thanks to the tool I found to import models into the game while developing the Synthetic Swarm mod (FileToVox in particular), I was able to make several copies of the sword as vox files with various scales. I did try to import the texture as well but it would generate way too much color variation for the customization feature I had in mind, so I ditched that and imported them with a unique texture, then added back the 3 different materials I wanted directly in MagicVoxel.
With a bunch of sword models ready I made the corresponding prefabs and loaded them in the editor to align the sword parts at the right location (some swords are too big to fit as a single object so the tool splitted them at the maximum size supported by MagicVoxel).
Once this was done I could start making the actual "tool" ingame ^^ First things first, as there was a bunch of abilities to choose from I wanted a nice selection wheel menu to pick one of them easily. I got inspired from the Everything Revolver too, but ended up making my own menu, which looks and behave pretty much exactly as what I had in mind so I am quite satisfied with it.
With my brand new selection menu ready, I started coding the sword spawning and deleting which was not much new to me, and I started implementing the three basic state a sword could be in: teleport, hold and fly. Initially I created those out of the constraint functions of the API as I thought it would make the sword interact more nicely with objects in the world, I ended up ditching this approach later in the process though as the game would not let me cut through unbreakable material with very large sword using constraints (swords would just stop at the first collision and eventually glitch out)... So the final version uses SetBodyTransform/SetBodyAngularVecloity functions instead which produces way smoother movements as well as allowing to phase through unbreakable matter a little more easily, there is still some pretty glitchy behaviour with that for the larger swords but this is just how the engine works at this point so I couldn't help it.
With my 3 basic sword control functions ready, I started to design the different formations for the Stances. Some of them were pretty easy as they relied on the same location and just used different sword rotations, some other were a bit more tricky and I to spend a lot of time debugging around which axis the swords were actually spinning until I got them to spin the right way X)
After completing all the stances, I took some time to build the Sword Mount as having the swords in your back always colliding with the ground was pretty annoying, so I wanted a reliable way to fly. Surprisingly this went really well at first try, all I did was to spawn a sword and place it exactly under the player feets. Then the regular player movement would make it move in all flat direction, and I just added a little up/down velocity to move on the vertical axis. There was a lot of momentum conservation with this method though so I ended up making a hard brake when the player is not pressing any key to make sure you can stabilize in the air easily.
Now in the air, I started adding the regular attacks using the base movement functions I made earlier, most of them were pretty straight forward: define a target, make the sword fly straight to that target. Some other were a bit more tricky like the Holy Hand or the Sea Dragon.
For the Holy Hand I adapted and reused the code of the player stance formations to make a second one in front of you. Then I had to tweak a lot the angles that the whole formation would take depending on the player camera movements, I was not sure which one felt the best, so I ended up adding a few mod options so that you can pick the one you prefer.
For the Sea Dragon, it took me some time to figure out a great way to make a snake pattern with the swords. My first idea was to make "blocks" with one leader sword in the center then 9 follower swords behind it with a slight offset to the back and to the side and then make the leader of each pack follow the leader of the previous pack. This was working decently but it would start to glitch out really hard when some of the leader sword enter a feedback loop after trying to phase through terrain for example... So I ended up using only the very first sword as reference to draw a path in the air, and then every other sword behind it reused that path to make its own trajectory. This approach was both more stable and it look way cooler and way closer to the picture I had in mind when I was thinking "Sea Dragon" so I am really happy with that one ^^
Once all the regular attacks were complete, I started creating the Titan Sword attacks. I think I had the Titan Sword assembling mechanic (gathering swords to level up) coded at some point in between other features but I forgot when exactly. Anyway I made its attacks and for the most part I could reuse mechanisms from the regular sword attacks so it was pretty easy. This is also the point when I noticed that Constraint controls for the sword would not work how I wanted them to work so I swapped to the other approach.
Maybe one of the Titan Sword attack was a bit tricky and it was the Titan Hand/Disk. For those I was not really sure how to make what I had in mind happen, so I ended up taking from the Sea Dragon idea and drawing a path for the sword to follow, except this time the path is drawn directly from the player mouse and not from a sword flying randomly. Then I had to interpolate the sword rotation between each node of the path to make it look somehow like a smooth movement. Not sure if this works in all situations, but for the most part it does the job as intended :)
Once all the sword related behaviours were coded, I had one last task: adding player animations! As 1.6.0 came out in the middle of the development of this mod there was very few existing mods to use for reference in order to animate a player model, so I had to scratch my head quite a lot with the new API functions to figure out what I needed to use and how... All in all I think the end result is acceptable, it's a bit stiff, especially for the few animated transitions I tried to add between different poses, but it gets there without glitching out or going to weird body angles, so at least we have that going for us X)
And last but not least, I remembered that all this mod worked based on collision physics to do destruction, and that some people (me included) will probably want to use it to damage modded enemies that won't take damage from physics but only from bullets or explosions... So I took back and adapted the code I placed on my Shards a while ago and added two options to generate a bullet/an explosion whenever the tip of the sword collides with a new object ;)
Last edited by Geneosis; 1 Nov, 2024 @ 11:26am
< >
Showing 1-1 of 1 comments
agent dvd 4 Dec, 2024 @ 12:54pm 
that's a lot of writing, though I really like the mod, would use it anytime a mod is possible for a fighting game if its in the downloadable mod menu thing (steam workshop)
< >
Showing 1-1 of 1 comments
Per page: 1530 50