Creating a KIS_Item that causes errors on ProtoPartSnapshot (triggering fallback) causes physics weirdness
Hexicube opened this issue ยท 1 comments
Issue: Random physics "kick" when using "new KIS_Item(Part p)" with a part that has a command module, which causes the KIS_Shared code to resort to fall-back code for ProtoPartSnapshot, where the bug lies.
It's worth noting that the "kick" occurs at the root part of the active vessel, suggesting the part in fact exists for 1 tick and is destroyed that tick once the game realises it's not supposed to be there. The results range from minor rotation and velocity changes to annihilation of half the vessel, as is the nature of 2 parts being inside each other.
Offending code: https://github.com/KospY/KIS/blob/master/Plugins/Source/KIS_Shared.cs#L155-L161 (catch statement for PartSnapshot).
Solution: De-activate temporary part before deleting it.
Bug is triggered both in GUI updates (had the issue when mousing over a part in my GUI) as well as on fixed update ticks. The nice one-line fix will remove the need for me to have an 80-line work-around.