Scaling a SCNNode

Asked by At

I am working on an iOS app where I have a node on screen that shrinks to nothing over 4 seconds. I need this node to always face the camera so I am using SCNBillboardConstraint() on my target node. However, if I use that the scaling action no longer works. What can I do?

My Code:

target.constraints = [SCNBillboardConstraint()]
let scale = CGFloat(0)
let action = SCNAction.scale(to: scale, duration: 4)

1 Answers

ARGeo On

Use the following code, it works fine:

let ship = scene.rootNode.childNode(withName: "ship", recursively: true)!

let constraint = SCNBillboardConstraint()
ship.constraints = [SCNBillboardConstraint()]

let scale = CGFloat(0.0)
let action = SCNAction.scale(to: scale, duration: 4)

Hope this helps.