skphysicsjoint

node.physicsBody.joints downcasting error

前提是你 提交于 2019-12-02 02:50:44
The following code gives an error - it appears the physics joints array have the class PKPhysicsJoint. Anyone have any ideas how I can iterate through the joints in Swift? The documentation does say that physicsBody.joints should return an array of SKPhysicsJoint. import SpriteKit let scene = SKScene(size: CGSize(width: 200, height: 200)) let nodeA = SKNode() let nodeB = SKNode() nodeA.physicsBody = SKPhysicsBody(circleOfRadius: 20) nodeB.physicsBody = SKPhysicsBody(circleOfRadius: 20) scene.addChild(nodeA) scene.addChild(nodeB) let joint = SKPhysicsJointFixed.jointWithBodyA(nodeA.physicsBody,

Incorrect behaviour with SKPhysicsJointPin when shouldEnableLimits is true and lowerAngleLimit and upperAngleLimit set

心不动则不痛 提交于 2019-11-30 04:26:12
问题 I currently have a ragdoll figure, which consists of a parent node (with no physics bodies attached), and lots of child nodes which each consist of a circle body. The circles are connected to each other using an SKPhysicsJointPin between each circle, as so: Each SKPhysicsJointPin has shouldEnableLimits = true , and I currently use a value of -0.05 and 0.05 for lowerAngleLimit and upperAngleLimit respectively. This works pretty well and prevents the shape from deforming too much, except when

How to rotate sprites around a joint

杀马特。学长 韩版系。学妹 提交于 2019-11-29 10:34:43
I need to make the arms and hands rotate around the center of the hook, as shown in the image below without them separating or changing their shape (no changes in the angles between arms and hands just rotation at A), as in the image below: I tried rotating the arms but this made them separate and change form. You can check out my code below: let hookCategoryName = "hook" let leftArmCategoryName = "leftArm" let rightArmCategoryName = "rightArm" let leftHandCategoryName = "leftHand" let rightHandCategoryName = "rightHand" let hookCategory : UInt32 = 0x1 << 0 let leftArmCategory : UInt32 = 0x1 <