0
votes

When I am creating a .sks scene in Xcode, I often need two nodes at the exact same x or y position to create a wall. I add rectangular physics bodies. They both have no friction whatsoever.

When I make a spritenode move over these collision bodies (I am using an impulse to the physics body) it acts as if there is a barrier between the two rectangles and I need to 'push' the node or make it jump to get over a boundary. As I stated, these nodes are perfectly in line with each other so nodes should be able to flow past them smoothly.

Any suggestions?

If you need any code/pictures I am using, please ask.

Edit: The answer

My problem was the collision platforms were colliding with each other, and so they were slightly pushed out by on the generation of all platforms.

The way to solve is to set these following values on the platforms: categoryBitMask to 1 collisionBitMask to 4294967294 which basically means they won't collide with each other.

Still new to swift, good to keep learning :P

1
Please show what categoryMask, collisionMask, etc. your are setting each node to.George
@George_E_2 I'm quite new to this still, sorry. Category and collision masks are both just 4294967295? I'm not sure what this means, I'll read about it. If this is important, please tell me and I'll change it.user10220414
Ah, got it. I set it so the platforms no longer collide with each other. Thanks for the pointer :Puser10220414

1 Answers

0
votes

I have already pointed @abc to the right answer. Just to explain why the masks are at 4294967295:

enter image description here

You can see that this is 32bits (all 1's with that number). Each bit is a different mask, and collisions and category masks look at these, to determine properties such as do they touch/collide. This means you have 32 masks you can make in your game.

If you want to understand how to make masks or combine masks, you can use Bitwise Operators. These operators can let you add masks together using the | (or) bitwise operator, or something similar. Please read the Apple Documentation I linked to.