I have two SKNode
objects. Their positions change when they collide.
How can I prevent that? At the same time, I still want to be able to respond to them c
You can achieve that by setting category, collision and contact bit masks.
uint32_t bodyABitMask = 1<<0;
uint32_t bodyBBitMask = 1<<1;
//A mask that defines which categories this physics body belongs to.
[bodyA setCategoryBitMask:bodyABitMask];
[bodyB setCategoryBitMask:bodyBBitMask];
//A mask that defines which categories of physics bodies
//can collide with this physics body.
[bodyA setCollisionBitMask:0];
[bodyB setCollisionBitMask:0];
//A mask that defines which categories of bodies cause
//intersection notifications with this physics body.
[bodyA setContactTestBitMask:bodyBBitMask];
[bodyB setContactTestBitMask:bodyABitMask];
In above case bodyA and bodyB cannot collide, but you will receive didBeginContact once they are in contact.