SpriteKit Collisions

nick5454nick5454 USUniversity ✭✭✭

I have 2 SKSpiteNodes and Im trying to set the bit mask properly to Keep a sprite from colliding. I'e.., allow sprite(player) to move through sprite(enemy)

public enum Sprites : uint { Player = 1, Enemy = 2, Ground = 4 }

`Player.PhysicsBody = new SKPhysicsBody();
Player.CategoryBitMask = (uint)Sprites.Player;
Player.Dynamic = true;
Player.CollisionBitMask = ~(uint)Enemy

Enemy.PhysicsBody = new SKPhysicsBody()
Enemy.CategoryBitMask = (uint)Sprites.Enemy;
Enemy.Dyamic = true;
Enemy.CollisionBitMask = ~(uint)Sprites.Player;`

But my Player won't go through the enemy. I need it dynamic because it is a player and can be blocked by the ground. Anyone know why this setup isn't working?

Posts

Sign In or Register to comment.