Jeremy White
Jeremy White

Reputation: 2829

How can I point an SCNNode at another SCNNode?

I have a series of (flat plane) nodes in my scene that I need to have constantly facing the camera.

How can I adjust the transform/rotation to get this working?

Also, where do I make this calculation?

Currently I am trying to make it happen on user interaction in the SCNSceneRendererDelegate renderer:updateAtTime: delegate method.

Upvotes: 2

Views: 882

Answers (1)

Hal Mueller
Hal Mueller

Reputation: 7655

How about an SCNBillboardConstraint? That restricts you to iOS 9/El Capitan/tvOS. Add the constraint to each of your flat plane (billboard) nodes.

From the SceneKit Framework Reference: https://developer.apple.com/library/ios/documentation/SceneKit/Reference/SCNBillboardConstraint_Class/index.html

An SCNBillboardConstraint object automatically adjusts a node’s orientation so that it always points toward the pointOfView node currently being used to render the scene.

In the more general case, SCNLookAtConstraint will keep any node's minus-Z axis pointed toward any other node.

Upvotes: 3

Related Questions