Pete
Pete

Reputation: 219

SceneKit Node To Follow Camera

I am attempting to have a text node in SceneKit always point towards me - that is towards my camera location. For some reason it does not rotate but stays static:

let text = SCNText(string: "My String", extrusionDepth: 0.1)
text.font = UIFont(name: "Arial", size: 10)
let textNode = SCNNode(geometry: text)
textNode.position = position

//Here I add the constraint to the SCNView's pointOfView node
let lookAtConstraint = SCNLookAtConstraint(target: scnView.pointOfView)
textNode.constraints = [lookAtConstraint] 

What am I missing here?

Upvotes: 0

Views: 589

Answers (1)

Sulevus
Sulevus

Reputation: 659

There is actually a type of constraint for this specific purpose. It's called SCNBillboardConstraint and it always orients the node it is assigned to towards the current camera. You don't even have to provide a target when initializing.

Upvotes: 1

Related Questions