I am working on an ARKit project in Swift Playgrounds and here is what I have right now:
Timer.scheduledTimer(timeInterval: 0.1, target: self, selector: #selector(self.animateSoldiers), userInfo: nil, repeats: true)
@objc func animateSoldiers() {
if self.soldiersPlacedCount >= self.numberOfSoldiers {
for node in self.allNodesSet {
if node.name!.contains("soldier") {
node.position = SCNVector3(x: node.position.x + 0.01, y: node.position.y, z: node.position.z)
let pitch = sceneView.session.currentFrame?.camera.eulerAngles.x
let yawn = sceneView.session.currentFrame?.camera.eulerAngles.y
let roll = sceneView.session.currentFrame?.camera.eulerAngles.z
let newRotation = SCNVector3Make(pitch!, yawn!, roll!)
node.eulerAngles = newRotation
}
}
}
}
I have narrowed down the issue to this method. The app crashes after running an arbitrary number of times when running on iPad. It keeps changing and I have no idea what is going on. Any help is appreciated!