I'm making a boxing game where each boxer is made up of sprite nodes attached using physics joints. The game works well but very rarely when I run a long automated test (chaos monkey style) the joints get tangled up, tear and the game crashes.
Here is a video of it happening see at 0.18.
https://www.youtube.com/watch?v=aHrjBdjNILc
Any idea what can be the cause and how I can strengthen the code and fix this annoying bug? I've spent hours looking into this now and any hints highly appreciated.
Here is a sample code how I setup the joints:
SKPhysicsJointSliding* neck = [SKPhysicsJointSliding jointWithBodyA:body.physicsBody
bodyB:head.physicsBody
anchor:head.position
axis:CGVectorMake(head.frame.size.width, 0)];
neck.shouldEnableLimits = YES;
neck.lowerDistanceLimit = 0.0;
neck.upperDistanceLimit = head.frame.size.width / 2;