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)
target.runAction(action)

1 Answers

0
ARGeo On

Use the following code, it works fine:

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

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

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

Hope this helps.