Skip to content

Commit 4157210

Browse files
authored
use prefab CoPOffset instead
Given stock code, this should always be 0 for everything except parts with ModuleProceduralFairing. But if some mod poked a different value into the prefab, this should be more correct. And if a mod poked a different module into the part instance, then we're kinda screwed anyway.
1 parent 42bc27d commit 4157210

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Source/Modules/ModuleCoPFollowTransform.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,11 @@ public override void OnLoad(ConfigNode node)
2626
if (followTransform == null) Debug.LogError($"[{MODULENAME}] transformName '{transformName}' was empty or does not exist on part '{part.partInfo?.name}'");
2727
}
2828

29-
if (followTransform == null)
29+
if (followTransform == null && part.partInfo != null)
3030
{
3131
// this may be important if someone is swapping out versions of this module with B9PS
32-
part.CoPOffset = Vector3.zero;
32+
// Note this probably isn't correct for parts that also have modules that mess with this field (e.g. ModuleProceduralFairing)
33+
part.CoPOffset = part.partInfo.CoPOffset;
3334
}
3435

3536
// NOTE: isEnabled will be persisted to the save file, but we want to treat it purely as runtime state

0 commit comments

Comments
 (0)