From a04c0eab4f9a145adde9d3f8275a634678f9d2d5 Mon Sep 17 00:00:00 2001 From: Juozas Kasiliauskas Date: Fri, 10 Jun 2022 16:42:33 +0300 Subject: [PATCH] Minor cleanup and comments --- .../Assets/ID_ExternalForces/ID_ExternalForces_Demo.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/InverseDynamicsDemoProject/Assets/ID_ExternalForces/ID_ExternalForces_Demo.cs b/InverseDynamicsDemoProject/Assets/ID_ExternalForces/ID_ExternalForces_Demo.cs index 093ddd3..d1c0b87 100644 --- a/InverseDynamicsDemoProject/Assets/ID_ExternalForces/ID_ExternalForces_Demo.cs +++ b/InverseDynamicsDemoProject/Assets/ID_ExternalForces/ID_ExternalForces_Demo.cs @@ -38,6 +38,8 @@ public class ID_ExternalForces_Demo : MonoBehaviour void FixedUpdate() { + // We apply the force here and clear the list, to ensure that all the forces were added + // only once and were added before we call GetJointExternalForces foreach (var body in m_Bodies) { body.AddForce(m_WindForce * Time.fixedDeltaTime* Random.Range(0.75f, 1.25f)); @@ -69,10 +71,9 @@ public class ID_ExternalForces_Demo : MonoBehaviour m_ButtonText.text = "Apply Forces: " + b_ApplyExternalForces; } - - private void OnTriggerStay(Collider other) { + // We collect the bodies that are in our trigger zone, but don't apply the force yet ArticulationBody ab = other.GetComponentInParent(); if (ab != null)