Reputation: 387
I followed this exactly: https://developer.apple.com/documentation/scenekit/animation/animating_scenekit_content
I have a SCNNode on another SCNNode that has the geometry of the user face.
The SCNNode that is on the face SCNNode, I would like the movement to be animated. I'm calling this function which is in a subclass of the SCNNode I want to animate. The property it takes is a location on the face. This function doesn't work at all:
func move(to vertex: SCNVector3) {
let animation = CABasicAnimation(keyPath: "move")
animation.fromValue = SCNVector3(self.position.x, self.position.y, self.position.z)
animation.toValue = vertex
animation.duration = 3.0
self.addAnimation(animation, forKey: "move")
}
This function works perfectly fine:
func move(to vertex: SCNVector3) {
self.position.x = vertex.x
self.position.y = vertex.y
self.position.z = vertex.z
}
The function call to both functions:
move(to: SCNVector3(anchor.geometry.vertices[Node.oldVertexPos].x, anchor.geometry.vertices[Node.oldVertexPos].y, anchor.geometry.vertices[Node.oldVertexPos].z))
Upvotes: 1
Views: 764
Reputation: 4850
The keyPath "move" doesn't exist on SCNNode, you should be animating the position.
let animation = CABasicAnimation(keyPath: "position")
Upvotes: 2