Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When AutoStrutDrift = true an extended piston will move in unexpected ways causing crafts to act unexpectedly #96

Closed
anth1256 opened this issue Sep 19, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@anth1256
Copy link

anth1256 commented Sep 19, 2022

AutoStrutDrift Bug Piston.zip

Tested with the following:
KSP 1.12.3 DLCs no mods
KSP 1.12.3 DLCs KSPCF/Harmony/modulemanager

KSPCommunityFixes_1.22.2
HarmonyKSP_2.2.1.0_for_KSP1.8+
ModuleManager.4.2.2.dll

Note that this problem happens when the piston is connected one way. If its connected to the other node this problem doesn't happen.

https://youtu.be/UYVAc9oj4Gw Video Evidence

Also note use of timewarp

@gotmachine gotmachine added the bug Something isn't working label Oct 5, 2022
@gotmachine
Copy link
Contributor

The AutoStrutDrift patch is supposed to skip handling autostruts targeting or originating to/from a servo part, mainly because there is some additional complexity in accounting for the servo current offset that I didn't have the courage to tackle.

But somehow, while I covered the "targeting to a servo" case, I forgot the "originating from a servo" case, resulting in the strut ignoring that the servo is extended and trying to pull it in the retracted position.

I will add the necessary check to fix this.
But ideally, I should try to implement the auto-strut correction even when servo parts are involved. Will try to take a look.

For reference, the fix is replacing this :

// We only correct autostruts directly connected to the main rigidbody of the part.
// Specifically, we don't handle autostruts connected to a BG robotic part.
// It might be possible to handle that case by getting the offset between the part and the servoRb, not entirely sure.
if (joint.connectedBody != anchor.rb)
{
#if DEBUG
Debug.Log($"[AutoStrutDrift] Skipping autostrut for {__instance}. The joint rb ({joint.connectedBody}) isn't the anchor rb ({anchor.rb}), the anchor is likely a robotics part");
#endif
return;
}

with

// We only correct autostruts directly connected to the main rigidbody of the part.
// Specifically, we don't handle autostruts connected from/to a BG robotic part.
// It might be possible to handle that case by getting the offset between the part and the servoRb, not entirely sure.
if (joint.connectedBody.NotDestroyedRefNotEquals(anchor.rb))
{
#if DEBUG
    Debug.Log($"[AutoStrutDrift] Skipping autostrut for {__instance}. The connected rb ({joint.connectedBody}) is different from the anchor rb ({anchor.rb}), the anchor is likely a robotics part");
#endif
    return;
}

if (__instance.Rigidbody.NotDestroyedRefNotEquals(joint.GetComponent<Rigidbody>()))
{
#if DEBUG
    Debug.Log($"[AutoStrutDrift] Skipping autostrut for {__instance}. The part rb ({__instance.Rigidbody}) is different from the rb hosting the joint ({joint.GetComponent<Rigidbody>()}), the part is likely a robotics part");
#endif
    return;
}

@gotmachine
Copy link
Contributor

Fixed in 1.25.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

No branches or pull requests

2 participants