I have a view that dynamically creates an SCNView. This scene is empty, but when I click the button, I would like to add node from a separate scn file. This file contains animation, and I would like it to be animated in the main scene. The problem is that after adding an object to the scene, it does not revive. When I use this file as an SCNView scene, it works. isPlaying and loop are included. What else do I need to do to import such a node with animation? Sample code below:
override func viewDidLoad() {
super.viewDidLoad()
let scene = SCNScene()
let sceneView = SCNView(frame: CGRect(x: 0, y: 0, width: 300, height: 300))
sceneView.scene = scene
sceneView.loops = true
sceneView.isPlaying = true
sceneView.autoenablesDefaultLighting = true
view.addSubview(sceneView)
let subNodeScene = SCNScene(named: "Serah_Animated.scn")!
let serah = subNodeScene.rootNode.childNode(withName: "main", recursively: false)!
scene.rootNode.addChildNode(serah)
}
source
share