I am learning SceneKit, and have a the following code that plays a sound when my ball hits a wall.
if contactNode.physicsBody?.categoryBitMask == CategoryWall {
let hitSound = sounds["bump"]!
ballNode.runAction(SCNAction.playAudio(hitSound, waitForCompletion: true))
}
This works, however I only wish to play the sound when the ball initially hits the wall, currently it is rolling along a wall, and this causes the sound to try and repeat and therefore causes problems.
I tried altering the waitForCompletion to false or true, this didn't help.
Is there a method or attribute that can be set to check for initial contact and then once contact is broken reset?
thanks in advance.
Kev