I am very new to SceneKit, only having worked with 2D applications so far. Although this question has already been asked, I am not advanced enough to understand the answers. I have a SCNNode that I want to move forward no matter where it's facing after any rotation is applied. Here is my current code for my forward, right, and left actions:
func moveForward() {
let moveForwardAction = SCNAction.move(by: SCNVector3(x:0, y:0, z:1) , duration: 0.5)
let startForwardAction = SCNAction.repeatForever((SCNAction.sequence([moveForwardAction])))
carNode.runAction(startForwardAction)
}
func moveLeft() {
let turnLeftAction = SCNAction.rotateTo(x: toRadians(angle: 0), y: toRadians(angle: 90), z: 0, duration: 2.0, usesShortestUnitArc: true)
let startLeftAction = SCNAction.repeatForever(SCNAction.sequence([turnLeftAction]))
carNode.runAction(startLeftAction)
}
func moveRight() {
let turnRightAction = SCNAction.rotateBy(x: toRadians(angle: 0), y: toRadians(angle: 90), z: 0, duration: 0.5)
let startRightAction = SCNAction.repeatForever(SCNAction.sequence([turnRightAction]))
carNode.runAction(startRightAction)
}
Is there any way someone can dumb it down for me and tell me what code I need to be inputting to get my desired outcome?