Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions Source/Modules/ModuleCoPFollowTransform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,23 @@ public class ModuleCoPFollowTransform : PartModule
[KSPField]
public string transformName;

[SerializeField]
private Transform followTransform;

public override void OnLoad(ConfigNode node)
{
base.OnLoad(node);
if (HighLogic.LoadedScene != GameScenes.LOADING)
if (followTransform == null || followTransform.name != transformName)
{
if (transformName != null) followTransform = part.FindModelTransform(transformName);
if (followTransform == null) Debug.LogError($"[{MODULENAME}] transformName was empty or does not exist.");
Copy link
Contributor

@JonnyOThan JonnyOThan Oct 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would be a good idea to include the transform name that was searched for in the error message.

Oh, right, I can just do that.

this.isEnabled = followTransform != null;
this.enabled = followTransform != null;
}
}

public void FixedUpdate()
{
if (!HighLogic.LoadedSceneIsFlight) return;
if (followTransform != null) part.CoPOffset = part.transform.InverseTransformPoint(followTransform.position);
}
}
Expand Down