KeenSoftwareHouse / SpaceEngineers

2.94k stars 895 forks source link

Joints break unexpectedly in multiplayer (landing gears, pistons, rotors, connectors, etc) #100

Open tuxillator opened 9 years ago

tuxillator commented 9 years ago

The "landing gear" bug.

Sometimes there are vibrations/wobbling at joints heralding impending doom. Detaching the joint (e.g. detaching a landing gear) would then cause sudden velocity change of one/both attached grids resulting in catastrophic collision damage to what it's attached to/anything close by.

Landing gears, rotors, pistons and connectors all seem to be affected by this issue, but I nickname it the landing gear bug as it's the easiest to reproduce and most dramatic during failure. Having multiple joints attached to a grid increases the probability/strength of the issue. Merge blocks are not affected as far as I can tell.

In-game the joint looks like it is accumulating energy, sometimes instantly or sometimes over time. I suspect a rounding error or similar possibly in the netcode (it happens very frequently in MP/DS, not sure about SP).

Until the root issue is resolved a possible workaround for shattering gears/connectors: during joint detachment, check relative velocity between grids and ensure they are sane. If not, forcibly set it to something reasonable before calling Physics.RemoveConstraint. Things are likely to keep wobbling but at least they don't shatter when you press p.

Hoping with source visibility the mod community may have advantage in eyeballs to finally close this out.

Drakoskai commented 9 years ago

It always seemed like the issue was related to the client and the server disagreeing on the location of the landing gear. I had never observed the issue in single player.

MeusRex commented 9 years ago

Actually you can force the bug in single player by building certain constructs. I for one managed to blew up two ships by building a grinder vessel with two grinders on two stacked pistons and four rotor arms with landing gears. If I had to hazard a guess I'd say the issue there were the forces applied by the grinders to both the grinder and the grindee which then were propagated to the other ships through the the landing gears, literally shaking the whole construct apart

An other time I saw this happen was in the patch introducing the endless world, when you moved from one cluster to the next. But haven't seen that one since the following patch.

Drakoskai commented 9 years ago

That's really good to know, but in this case is it "Works as intended"? Are things supposed to explode like this if under too much stress and what we see with the landing gears is a bug related to proper behavior?

Mihara commented 9 years ago

Landing gears can also produce bizarre phantom forces when active. For example, one of my ships -- a carrier with a large deck -- would keep spinning despite the gyroscopes. Turned out, two of the smaller craft on deck ended up embedded a few centimeters into the deck and disengaging them would wreck them and the deck, but stop spinning. After a reload, the server can disagree on the relative positions of the objects involved with itself, though this happens much less often than multiplayer desync.

thelastWallE commented 9 years ago

I just found this. Can someone with more knowledge look at it? http://anarchy.cn/manual/12/HavokSdk_ProgrammersManual/classhkpConstraintStabilizationUtil_ace46b392eb13a611a40cedabdc5e2368.html#ace46b392eb13a611a40cedabdc5e2368 Maybe just call this after Line 570 in Sandbox.Game\Game\Entities\Blocks\MyLandingGear.cs??

    m_constraint = new HkConstraint(CubeGrid.Physics.RigidBody, body, data);
    CubeGrid.Physics.AddConstraint(m_constraint);
    m_constraint.Enabled = true;

It is from this class http://anarchy.cn/manual/12/HavokSdk_ProgrammersManual/classhkpConstraintStabilizationUtil.html

Drakoskai commented 9 years ago

Good catch. I took a quick look, I don't see anyway to access that class since it's in the Havok dll. I'll keep looking though -- my specialty isn't C# so I may be missing something. Anyone else looking?

jmosul commented 8 years ago

We're having this issue too, we have a piston on a large ship which breaks in half when landing gears are unlocked. Bit annoying, the piston and the landing gears were integral to the ship's design.

We're on multiplayer, version 01.119.014, build 2016-01-29 05:52