How do you get positional audio to work in SceneKit?

I am having trouble getting positional audio to work in SceneKit. Starting with the SceneKit game template generated by Xcode I have added the following code to the end of the handleTap method:

let ship = scnView.scene!.rootNode.childNode(withName: "ship", recursively: true)!  
if let source = SCNAudioSource(fileNamed: "art.scnassets/monoAudioTest.wav")  
{  
    source.volume = 1  
    source.isPositional = true  
    source.shouldStream = true  
    source.loops = true  
    source.load()  
    let player = SCNAudioPlayer(source: source)  
    ship.addAudioPlayer(player)  
}  

ship.runAction(SCNAction.move(to: SCNVector3(0, 0, -10000), duration: 8)) 

The audio plays but the volume doesn’t decrease as the jet moves away from the camera. Am I missing some steps or making some wrong assumptions?

  • How to scroll to the bottom of a UITableView on the iPhone before the view appears
  • Add a ScrollView to existing View
  • Customize UISearchBar: Trying to get rid of the 1px black line underneath the search bar
  • iOS measuring web page loading time
  • More efficient way to retrieve Firebase Data?
  • iOS convert large numbers to smaller format
  • Cross-posted to the Apple Developer Forums.

    2 Solutions Collect From Internet About “How do you get positional audio to work in SceneKit?”

    You should be able to get positional audio with source.shouldStream = false.

    As mentioned by Jed Soane, and confirmed by Apple in a Radar, the issue was my audio file was stereo instead of mono. Only mono audio files will work for positional audio.