There are two physics bodies: an AirplaneNode
:
- (id)initAirplaneNode {
self = [super initWithImageNamed:@"airplane.png"];
if (self) {
self.name = @"player";
self.physicsBody = [SKPhysicsBody bodyWithRectangleOfSize:self.frame.size];
self.physicsBody.dynamic = NO;
self.physicsBody.affectedByGravity = NO;
self.physicsBody.categoryBitMask = AIRPLANE_CATEGORY;
self.physicsBody.contactTestBitMask = BULLET_CATEGORY;
}
return self;
}
and a BulletNode
:
- (id)initBulletNode {
self = [super initWithImageNamed:@"bullet.png"];
if (self) {
self.name = @"bullet";
self.physicsBody = [SKPhysicsBody bodyWithRectangleOfSize:self.frame.size];
self.physicsBody.dynamic = NO;
self.physicsBody.usesPreciseCollisionDetection = YES;
self.physicsBody.categoryBitMask = BULLET_CATEGORY;
self.physicsBody.contactTestBitMask = AIRPLANE_CATEGORY;
}
return self;
}
Both of them have physicsBody.dynamic
property set to NO
.
The problem is when a bullet hits an airplane, my SKScene
doesn't call didBeginContact
method. However, if I specify physicsBody.dynamic
property to YES
for either AirplaneNode
or BulletNode
, didBeginContact
is firing.
Is there a way to fix that?
PS: I really don't need my nodes to be dynamic, because it causes an unwanted behaviour: an airplane slightly moves when getting damaged and a bullet sometimes rotates when flying.