1

I have a Ball (categoryBitMask = 1, Contact =2), walls (categoryBitMask = 2, Contact = 1) and a Ground (with PhysicsBody for Ball to drop down)

I set physicsBody for all of it.

But I just want to Ball and Walls contact, not Ball with Ground.

In didBeginContact() when Ball drop to Ground, it's also called.

How can i ?

  • Show the exact code you are using (eg. how you set bit masks from Ball and a Ground). In short : `ball.contactTestBitMask = Collider.Wall.rawValue` and `ground.contactTestBitMask = 0` (you don't have to explicitly set this, because it is a default value). See this as well: http://stackoverflow.com/a/31111039/3402095 – Whirlwind Apr 09 '16 at 16:20

1 Answers1

0

In the category Enum, set 3 categories: (land, walls, Ball).

To set nil Contact for Ball and Land, I just set Contact for walls, not for Ball and Land:

wallsNode.physicsBody?.categoryBitMask = categoryType.walls.rawValue

To make ball not contact with Land, do this:

wallsNode.physicsBody?.contactTestBitMask = categoryType.ball.rawValue | categoryType.land.rawValue

And this:

wallsNode.physicsBody?.collisionBitMask = categoryType.ball.rawValue | categoryType.land.rawValue
Whirlwind
  • 14,286
  • 11
  • 68
  • 157