1
votes

I'm looking for a way to remove a node when the player comes in contact with it. (Ex Coins in a game)

func didBeginContact(contact: SKPhysicsContact) {

    if contact.bodyA.categoryBitMask == ColliderType.Coin.rawValue || contact.bodyB.categoryBitMask == ColliderType.Coin.rawValue {

        //Delete that coin

}
1

1 Answers

2
votes

Nevermind found it!

func didBeginContact(contact: SKPhysicsContact) {

if contact.bodyA.categoryBitMask == ColliderType.Coin.rawValue || contact.bodyB.categoryBitMask == ColliderType.Coin.rawValue {

    contact.bodyA.node?.removeFromParent()

}