I am trying to merge several sprite nodes into a single unified physics body. For example:
I am trying to unify these three barriers into a single sprite node. I have looked at other questions and I have tried the following:
Making one of the nodes the parent, adding the other nodes to the parent and setting them non-dynamic. However, this disables the movement of the children nodes.
I tried creating a node with the a physics body of all the other barriers:
SKPhysicsBody(bodies: self.allNodePhysicsBodies)
I also tried creating a joint of the nodes with the "parent" node:
let joint = SKPhysicsJointFixed.joint(withBodyA: merge[0].physicsBody!, bodyB: merge[1].physicsBody!, anchor: CGPoint(x: 0, y: 0)) let joint1 = SKPhysicsJointFixed.joint(withBodyA: merge[0].physicsBody!, bodyB: merge[2].physicsBody!, anchor: CGPoint(x: 0, y: 0)) self.physicsWorld.add(joint1) self.physicsWorld.add(joint)
However, this does not unite the physics bodies. It does not create a single physics body.
How can I accomplish this? I was thinking my only option was to unite the textures before I even create the node.
EDIT
Attempt to unite the barriers with a physics body again:
let ourUnionOfBodies = SKPhysicsBody(bodies: [merge[0].physicsBody!, merge[1].physicsBody!, merge[2].physicsBody!])
ourUnionOfBodies.isDynamic = true
merge[2].physicsBody = ourUnionOfBodies