I have a SKSpriteNode called "SpikyRedBall" which is a red ball. I wanted to add spikes to it so I used the following code. I can see the Spike attached to the ball but when the ball collides with another ball it does not take the fixed joints into consideration and moves them separately. I am using the following implementation:
@implementation SpikyRedBall
-(instancetype) init
{
self = [super init];
[self attachSpikes];
return self;
}
-(void) attachSpikes
{
Spike *spike = [[Spike alloc] init];
spike.position = CGPointMake(0, 0);
// attach the joint
SKPhysicsJointFixed *ballAndSpikeJointFixed = [SKPhysicsJointFixed jointWithBodyA:self.physicsBody bodyB:spike.physicsBody anchor:CGPointZero];
[self.scene.physicsWorld addJoint:ballAndSpikeJointFixed];
[self addChild:spike];
}
@end
It sounds like you don't have collision or contact categories setup for the spikes themselves. I would try setting all physicsBody properties on the spikes to be identical to those of the balls, but obviously ensuring that they don't have collision or contact categories setup in a way that they would collide with their own parent ball.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With