我正在使用这段代码为飞机的高度设置动画。
func animPlane2(){
let animSize = CABasicAnimation(keyPath: "height")
animSize.duration = 1.5
animSize.byValue = 40
animSize.repeatCount = Float.infinity
animSize.autoreverses = true
planeNode.addAnimation(animSize, forKey: nil)
}
调试器抛出: [SCNKit 错误] 高度不是动画路径(来自 | 没有 child >)
关于飞机高度的文档说明:
The extent of the plane along its vertical axis. Animatable.
这是错误还是我做错了什么?
最佳答案
SCNNode
没有名为 height
的属性。这是您指定为节点几何形状的 SCNPlane
的一个属性,因此这是您需要向其添加动画的部分:
planeNode.geometry?.addAnimation(animSize, forKey: nil)
或者,您可以将动画添加到节点,但设置其 keyPath 以影响几何体的高度:
let animSize = CABasicAnimation(keyPath: "geometry.height")
// ...
planeNode.addAnimation(animSize, forKey: nil)
关于ios - SCNPlane 的高度没有动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31081327/