Swift - sprite kit - make SKPhysicsJointPin have less motion -
i'm trying create snake multiple body parts moves left , right. im using pin, upon snake stopping, body keeps moving , doesn't stop. i've messed around max , min angles, , torque, nothing seems work. should use different type of joint?
sorry cant log other account, heres code. second part wobbles lot. wish add 7-8 parts, keep on wobbling, after moving "head". fluid "swoop" motion when move snake.
self.physicsworld.gravity = cgvectormake(0, -100) self.physicsworld.contactdelegate = self head.size = cgsize(width: 25,height: 25) head.physicsbody = skphysicsbody(texture: head.texture, size: head.size) head.position = cgpointmake(100,400) head.anchorpoint = cgpoint(x: 0.5, y: 1) head.physicsbody!.dynamic = false head.zposition = 3 self.addchild(head) var p1 = skspritenode(imagenamed: "snakebodypart.png") p1.size = cgsize(width: 25,height: 25) p1.physicsbody = skphysicsbody(texture: p1.texture, size: p1.size) p1.position = cgpointmake(100,380) p1.anchorpoint = cgpoint(x: 0.5, y: 1) p1.physicsbody!.dynamic = true addchild(p1) var joint = skphysicsjointpin.jointwithbodya(head.physicsbody, bodyb: p1.physicsbody, anchor: cgpoint(x: cgrectgetmidx(head.frame), y: cgrectgetminy(head.frame) + 10)) joint.upperanglelimit = 0.1 joint.rotationspeed = 0.1 self.physicsworld.addjoint(joint)
Comments
Post a Comment