Desired behaviour
- The red node (players arm) is connected to the blue one with a pinned joint.
- The red node has a
physicsBody
because: 1) it should move if the blue node does and 2) it should collide with the rest of the world but not with the blue shape - Vice versa: The blue node (players body) should collide with the rest of the world – but obviously not with the red node.
Problem
Nodes and joint are setup fine (see left), but the physicsBody
do interact with each other (right):
Please note: In order to get the joint right I’ve had to add a child node (circle) to the red shape (players arm). So we’re talking about three nodes in total here.
Recent attempt
Tried a bunch of things. Following Apples’ documentation and this thread I learned that this could be solved with the correct combination of categoryBitMask
and collisionBitMask
.
BitMasks:
struct Category {
static let none: UInt32 = 0
static let all: UInt32 = UInt32.max
static let playerBody: UInt32 = 0b1 // 1
static let playerArm: UInt32 = 0b10 // 2
static let regularObject: UInt32 = 0b100 // 4
}
Blue Shape:
body.categoryBitMask = Category.playerBody
body.collisionBitMask = Category.all
Red Shape (as well as its child node for the joint):
body.categoryBitMask = Category.playerArm
body.collisionBitMask = Category.none
... but this did not solve the problem.
Struggeling for three days in a row now. I know this sort of question got already asked a numerous of times but none of them lead me to the right direction. Really appreciate any advice!