I've been making fun small games for myself over the last few years, everything I know about coding has been read online, so I'm very inexperienced. I have recently started working with SceneKit and get lots of no reoccuring bad access errors. They all seem to come in my if let n = scene.rootnode.childnode
calls which you can see below and I'm not sure why. I know the node that I'm calling exists and has the correct name. I can run the exact same scenario 5 times in a row and 2 of them will give me the bad access error. The exact error code is EXC_BAD_ACCESS (code=EXC_I386_GPFLT). I have read a few things about this error and have tried command-K to clear console and that didn't help. I get this error on both simulator and real device. Any advice or knowledge would be appreciated. Thanks.
@objc func waveTick() {
let teamDef = -1*teamInv + 3
var num1 = 0
let nodesCur = actNodes[teamInv-1]
while (num1 < nodesCur.count){
num1 += 1
if let n = scene.rootNode.childNode(withName: "NODE" + String(nodesCur[num1-1]), recursively: false) as? HelpNode {
if (n.tick == tick && n.invador) {
enemyBrain(enemy: n)
}
}
}