0

I would like to add a new superpower to my superhero in a spritekit game.

Once this superpower is enabled, he will be able to pass through any other SKPhysicsBody.

Setting the contactTestBitMask to 0x00000000 will only disable contact detection (didBeginContact:).

self.hero.physicsBody.contactTestBitMask = 0x00000000;

while setting dynamic to NO will let it pass through any SKPhysics body (but at the same time it will disable the gravitational force as well)

self.hero.physicsBody.dynamic = NO;

I want it to pass through the hero instead of just disabling the contact detection.

How to achieve this?

user1872384
  • 6,886
  • 11
  • 61
  • 103
  • Reason for down voting please? It's not like you can just set the physicsBody = nil, since i still need gravity to act on the hero. – user1872384 Mar 24 '14 at 03:50
  • Hi rickster i've tried setting self.hero.physicsBody.collisionBitMask = 0x00000000; didn't work as well. Probably I don't understand collisionBitMask that well. – user1872384 Mar 24 '14 at 05:44
  • From the document, "this body’s collision mask is compared to the other body’s category mask by performing a logical AND operation. If the result is a non-zero value, then this body is affected by the collision."So if i'm setting the hero collisionBitMask to 0x00000000, which means the result will be zero, and no collision will occur right? – user1872384 Mar 24 '14 at 05:59
  • 1
    @user1872384 Can you please paste more code? – Andrey Gordeev Mar 24 '14 at 08:47
  • @rickster thank you so much! it's working! Can you please post your answer at the bottom so that I can mark it as a correct answer? – user1872384 Mar 24 '14 at 13:25
  • thank you for offering your help @AndreyGordeev. Just a minor bug which causes collisionBitMask resetting itself. – user1872384 Mar 24 '14 at 13:27

0 Answers0