I'm trying to build my first ARKit app. The purpose of the app is to shoot little blocks in the direction that the camera is facing. Right now, here is the code I have.
sceneView.scene.physicsWorld.gravity = SCNVector3(x: 0, y: 0, z: -9.8)
@IBAction func tapScreen() {
if let camera = self.sceneView.pointOfView {
let sphere = NodeGenerator.generateCubeInFrontOf(node: camera, physics: true)
self.sceneView.scene.rootNode.addChildNode(sphere)
var isSphereAdded = true
print("Added box to scene")
}
}
The gravity works fine, whenever I tap on the screen the block shoots out each and every time I tap. However, they all shoot to the same point, no matter which direction the camera is facing. I'm trying to understand how pointOfView works, would I need to re-render the whole scene? Something else that I can't quite think of? Thanks for any help!