I'm making a game with swift 3 and spritekit and I need a way to have an object with a physicsbody pass through another physicsbody while still detecting the collision but not bouncing off of it (sort of a checkpoint system so I can tell how many stages the player has gone through)
Asked
Active
Viewed 352 times
1
-
This might help: http://stackoverflow.com/a/21268099/819340 – Paulo Mattos Apr 20 '17 at 01:37
1 Answers
0
As pointed out by @PauloMattos; setting the contactTestBitMask of the two objects will fire the didBegin func where you can check which objects have collided and increment your stages if needed. If you don't have the collisionBitMask set for those two objects the objects will pass through each other vs. bouncing off each other.
It is also worth pointing out that when detecting contact the didBegin func will keep detecting the contact the whole time that the object is travelling through the other object. This could result in your stages getting incremented hundreds of times instead of once. What you can do is set a flag once you detect that contact so that you can filter out the rest of the contact between the two objects.

Ron Myschuk
- 6,011
- 2
- 20
- 32