void UpdateSleepiness() { if (bodyID == IntPtr.Zero) { return; } Ode.dBodySetAutoDisableFlag(bodyID, (Sleepiness == 0) ? 0 : 1); // As value goes from 0.0 to 1.0: // AutoDisableLinearThreshold goes from min to max, // AutoDisableAngularThreshold goes from min to max, // AutoDisableSteps goes from max to min, // AutoDisableTime goes from max to min. float range = Defines.autoDisableLinearMax - Defines.autoDisableLinearMin; Ode.dBodySetAutoDisableLinearThreshold(bodyID, Sleepiness * range + Defines.autoDisableLinearMin); range = Defines.autoDisableAngularMax - Defines.autoDisableAngularMin; Ode.dBodySetAutoDisableAngularThreshold(bodyID, Sleepiness * range + Defines.autoDisableAngularMin); range = (Defines.autoDisableStepsMax - Defines.autoDisableStepsMin); Ode.dBodySetAutoDisableSteps(bodyID, (int)(Defines.autoDisableStepsMax - Sleepiness * range)); range = Defines.autoDisableTimeMax - Defines.autoDisableTimeMin; Ode.dBodySetAutoDisableTime(bodyID, Defines.autoDisableTimeMax - Sleepiness * range); }