Kerbal Attachment System (KAS)

Kerbal Attachment System (KAS)

2M Downloads

Using kOS to call winch eject event behaves differently to mouse click

chrisb2244 opened this issue ยท 1 comments

commented

Issue already reported at kOS github issue tracker: KSP-KOS/KOS#1998

When clicking the eject button in KAS, either on the PartModule menu from right-clicking on the winch, or from the GUI opened with 'Show GUI', the harpoon ejects properly, flies down and hits the ground (approximately 60cm away in my test case). The harpoon is embedded, and the cable 'auto-stretches', or similar, becoming approximately tight.

When calling (example kOS code)
set winchModule to ship:partsdubbed("KAS.Winch2")[0]:getmodule("KASModuleWinch"). winchModule:doevent("Eject").
the harpoon is ejected with almost no force.

The comparison lines from the output_log.txt are as follows:

Projectile KAS.Hook.Harpoon (UnityEngine.Rigidbody) has been ejected at speed 11.42716. Max cable length 50 will be exahusted in 4.37554 seconds.

vs

Projectile KAS.Hook.Harpoon (UnityEngine.Rigidbody) has been ejected at speed 0.03056387. Max cable length 50 will be exahusted in 1635.918 seconds.

The upward force on the probe is also noticeably different.

Discussion in the kOS issue is looking at a possible workaround, but it was also suggested that the fix might be dependent on KAS. In either case, I hoped that someone here might be able to provide information as to a workaround, or where a fix could be applied in either codebase (if appropriate).

commented

The harpoon eject action adds a force to the harpoon in mode ForceMode.Force which means the actual velocity will depend on the mass of the harpoon being ejected. I'm not familiar with kOS but command ship:partsdubbed makes me think there is a part copy action being done. If so, I'd double check if the part's Rigidbody mass is properly set before the eject action is executed.