0

I'm trying to bind two nodes together with a fixed SKPhysicsJoint I came up with this Code:

var anchor = CGPointMake(hero.position.x + 10,hero.position.y)
var fixedJoint = [SKPhysicsJointFixed .jointWithBodyA(hero.physicsBody!, bodyB: shield.physicsBody!, anchor: anchor)]

the problem came with:

self.physicsWorld.addJoint(fixedJoint)

It gave me this error:

Cannot convert value of type '[SKPhysicsJointFixed]' to expected argument type 'SKPhysicsJoint'

Any help is appreciated.

GTG101
  • 149
  • 13

1 Answers1

1

You put the fixedJoint into an array, try this instead, omitting [ and ].

let anchor = CGPointMake(hero.position.x + 10,hero.position.y)
let fixedJoint = SKPhysicsJointFixed.jointWithBodyA(hero.physicsBody!, bodyB: shield.physicsBody!, anchor: anchor)

Note: If you are not mutating your properties make them let instead of var.

crashoverride777
  • 10,581
  • 2
  • 32
  • 56