Project

General

Profile

Bug #2412

ModuleDecouple - forces added incorrectly.

Added by swamp_ig almost 10 years ago. Updated over 7 years ago.

Status:
Closed
Severity:
Normal
Assignee:
-
Category:
Physics
Target version:
-
Start date:
04/23/2014
% Done:

100%

Version:
Platform:
Any
Expansion:
Language:
English (US)
Mod Related:
No
Votes:
Arrow u r green
Arrow d r red

Description

Hi.

I've tracked down an issue in ModuleDecouple. In the method OnDecouple it seems to use:

current.Rigidbody.AddForce(a * (-this.ejectionForce / (float)num), ForceMode.Force)

This will just add an instantaneous force during a single physics frame, which is unfortunately of variable length.
Because of this, if you have phys warp active you get much more force when you activate the decoupler.

The fix would best be to add in a field:

[KSPField]
public float ejectionImpulse = 10f * 0.02f;

You could just get rid of ejectionForce and modify the seven parts that use it, alternately modify OnStart to maintain backward compatibility:

public override void OnStart(PartModule.StartState state)
{
    if(ejectionForce != 10 && ejectionImpulse == 0.2f)
        ejectionImpulse = ejectionForce * 0.02f;
    // ... rest of the code

Then just change the calls to AddForce:

current.Rigidbody.AddForce(a * (-this.*ejectionImpulse* / (float)num), ForceMode.*Impulse*);

History

#1 Updated by swamp_ig almost 10 years ago

Sorry about the ejectionImpulse there, was trying to bold preformatted code

#2 Updated by TriggerAu over 7 years ago

  • Status changed from New to Needs Clarification

#3 Updated by TriggerAu over 7 years ago

  • Status changed from Needs Clarification to Closed
  • % Done changed from 0 to 100

Closing this report out for now. If you find it is still occuring in the latest version of KSP please open a new report (and this one can be linked to it.) For best results, the wiki contains really useful info for when creating a report http://bugs.kerbalspaceprogram.com/projects/ksp/wiki.

You can also ask questions about the bug cleanup in the forum here: http://forum.kerbalspaceprogram.com/index.php?/topic/143980-time-to-clean-up-the-bug-tracker/ and tag @TriggerAu to get my attention

Also available in: Atom PDF