0

I am creating a leg kicking motion using two physics bodies for now; a body and a leg. I use a pin joint to connect the two bodies, apply angle limits to restrict the leg movement, and apply a torque impulse to kick the leg. All works well.

However, my character also has the ability to jump (just by applying an upward impulse to the body) and this seems to cause a problem to my pin joint's limits. The limits begin to glitch out when the character is upside down, particularly when the character's zRotation moves between PI and -PI, i.e. either side of directly upside down.

This seems strange because the joint limits work well when standing the correct way up. Has anyone ever seen a similar issue when using an SKPhysicsJointPin object with limits set up?

For completeness, the physics bodies are simple bodyWithRectangleOfSize: bodies, the leg node is a child of the body node (so rotates with it), and this is how I setup my pin joint:

CGPoint topOfLegAnchor = CGPointMake(0.0, [leg size].height / 2.0);
topOfLegAnchor = [[self scene] convertPoint:topOfLegAnchor fromNode:leg];
SKPhysicsJointPin *pinnedJoint = [SKPhysicsJointPin jointWithBodyA:[body physicsBody]
                                                             bodyB:[leg physicsBody]
                                                            anchor:topOfLegAnchor];
[pinnedJoint setShouldEnableLimits:YES];
[pinnedJoint setLowerAngleLimit:-M_PI_2];
[pinnedJoint setUpperAngleLimit:0.0];
Andy Barnard
  • 696
  • 1
  • 5
  • 15
  • What does "begin to glitch out" mean? How does it behave? – 0x141E Aug 30 '14 at 07:55
  • This seems to be related to my recent question: http://stackoverflow.com/questions/25555113/incorrect-behaviour-with-skphysicsjointpin-when-shouldenablelimits-is-true-and-l - My best guess is that the glitches happen when Sprite Kit automatically normalises the zRotation for the nodes; it doesn't take into account the joint's angles. It's probably a problem with Sprite Kit and I've filed a bug with Apple. – Robert Sep 02 '14 at 11:06
  • Robert's issue appears to be identical to mine so see that for an explanation of 'glitch out'. Thanks Robert. – Andy Barnard Sep 07 '14 at 08:40
  • any responses from Apple? – JakubKnejzlik Nov 15 '15 at 10:42

0 Answers0