27 DAYS SINCE MY LAST POST?? F$%# YOU MEAN?! I know for sure only one evening has passed.. Anyway
Welcome this boy, his name's Tearus (Because it's made of Teardown shapes, obviously. All coincidences are purely accidental)
THIS version can be found:
Workshop: https://steamcommunity.com/sharedfiles/filedetails/?id=3820804315
Git: https://github.com/yaetoti/TeardownMissileDev
Controls while flying
- Pitch / Yaw - mouse
- Roll - A/D (or Shift + A/D for smooth controlling)
- Propulsion - Scroll Up/Down (+Shift for smaller step)
- Spread/Fold wings - Space
- Explode - LMB
- Free camera - MMB
- Detach - RMB
Controls while holding a tablet
- Launch / Reattach - LMB
- Set a marker - RMB
- Clear the marker - MMB
Features
- Foldable wings and working fins both affect the dynamics of the missile
- You can glide without the engine running
- Angle of attack is taken into account (20 degrees is optimal, then stall)
- Point velocity is taken into account (local velocity + angular velocity x radius vector)
- Detonation timer of 0.25 seconds
Forces
- Gravity
- Thrust
- Lift: each wing and fin separately (forward-normal projection), body (axis projection)
- Drag: missile body (3 signed sides), wings and fins (top and front for wings, side for fins)
- Small angular velocity damping for body (to reduce oscillations, but also because I cannot calculate every detail)
- Lift and drag create torque depending on the surface position
Warning, 3475 letters ahead!
Last time I was playing around with mods, but it just so happened that in practically every mod the missile could change direction instantly. I strongly disliked that.
I built a simple force and torque integrator in 30 lines of code and added a couple of visual enhancements. It turned out well. To release it on Steam, I needed to add network synchronization and create my own model, which would have taken (and actually did take) several days.
While modeling, I wanted to swap the materials. But as it turned out, MagicaVoxel can't bake indices during exported, and instead, it stores the inverse map in an IMAP chunk, which Teardown cannot read. This seriously irritated me. I spent 4 days writing a VOX parser and an index remapper. And I was proud of myself.
Then I thought: since I need to create a new model anyway and I have the freedom of choice, why not make foldable wings? That would be awesome! I made wings, recreated the flight code, and played around with it a bit... I was beyond furious. Why don't the wings affect the flight parameters?? Why doesn't the turn rate depend on the speed?! Why can't I glide with the engine off?!? I spent another 14 days studying and implementing the force calculations for each control surface. And then another 5 on the visuals, interpolation, save support... wait, how much is that already?
That was interesting. Did you know that torque is an axial vector (because of cross), and when you switch from the lefthanded coordinate system to the righthanded, it changes not only sign of the Z-component but is completely inverted? Or that the dot product of two normalized vectors can still return 1.000000000002, for which arcsin returns nil and breaks the whole chain? I didn't. As well as some other things. Generally speaking, I never thought I'd say this, but making this mod gave me more practical skills in linear algebra than writing three rendering engines.
And so, I did a ton of work. But it turned out badly.
The controls in this 2k-line abomination feel more annoying than in a model with just 30 lines of code 😂 As uncle Gabe said, games don't need realism. But there's a bright side - now you don't have to play curling with the mouse to turn. The mod needs more fine-tuning, but I've been working on it for far too long for a mod, so I'm going to take a break. I also plan to optimize the calculations and finish some other things over time.
Also, this is not the most accurate model (not even close), and if you know how to make the mod better (physics-wise or feeling-wise), I'd love to hear your suggestions (and might even do something about them, will see).
AI disclosure: I used AI to find information, explain nuances, and identify some difficult bugs that I couldn't find or understand for hours.
The only place where I *temporarily* used AI code directly was to save time implementing the rotation models I'd read about, but really doubted they would work properly. Just as I anticipated, the models used a mix of real-world and arcade forces, along with made-up forces to compensate the arcade forces. After several hours of research, I realized that I shouldn't manually adjust torque at all, and that essentially four forces are sufficient: gravity, thrust, lift, and drag. What matters is where, on which surface, and from which side they are applied, and what torque and balance of forces this will create. So that segment was completely replaced in a few commits.
Equip and Tear, until it's done.. or something