From 481829c873d76b5c3d8e64e65af6241011a6d36a Mon Sep 17 00:00:00 2001 From: Pascal Serrarens Date: Tue, 10 Mar 2026 10:10:06 +0100 Subject: [PATCH] Ensure model follows target in editor --- CreatureControl/Runtime/Scripts/Creature.cs | 7 +++++++ CreatureControl/Runtime/Scripts/TargetLeg.cs | 13 +++---------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/CreatureControl/Runtime/Scripts/Creature.cs b/CreatureControl/Runtime/Scripts/Creature.cs index b98a842..7319836 100644 --- a/CreatureControl/Runtime/Scripts/Creature.cs +++ b/CreatureControl/Runtime/Scripts/Creature.cs @@ -94,6 +94,13 @@ namespace Passer.CreatureControl { } #endregion Update + + void OnDrawGizmos() { + // This ensures that the model is always following the target rig + if (Application.isPlaying == false) { + this.Update(); + } + } } } \ No newline at end of file diff --git a/CreatureControl/Runtime/Scripts/TargetLeg.cs b/CreatureControl/Runtime/Scripts/TargetLeg.cs index 8c4ed72..c0749a5 100644 --- a/CreatureControl/Runtime/Scripts/TargetLeg.cs +++ b/CreatureControl/Runtime/Scripts/TargetLeg.cs @@ -14,17 +14,14 @@ namespace Passer.CreatureControl { public Quaternion targetToBoneFemur; public Quaternion targetToBoneTibia; - private void Start() { } - public void MatchTo(Leg leg) { this.femurTarget.position = leg.femur.position; this.tibiaTarget.position = leg.tibia.position; this.tarsusTarget.position = leg.tarsus.position; - targetToBoneFemur = InsectRig.TargetToBoneRotation(leg.femur, leg.tibia); - targetToBoneTibia = InsectRig.TargetToBoneRotation(leg.tibia, leg.tarsus); + targetToBoneFemur = TargetRig.TargetToBoneRotation(leg.femur, leg.tibia); + targetToBoneTibia = TargetRig.TargetToBoneRotation(leg.tibia, leg.tarsus); - this.target.position = this.tarsusTarget.position; - this.target.rotation = this.tarsusTarget.rotation; + this.target.SetPositionAndRotation(this.tarsusTarget.position, this.tarsusTarget.rotation); } public virtual void OnDrawGizmosSelected() { @@ -133,10 +130,6 @@ namespace Passer.CreatureControl { return (float)angle; } - private static float Square(float x) { - return x * x; - } - #endregion Math }