Search code examples
iosscenekit

Explanation of convertPosition in SceneKit


I'll explain my scenario first. I have a camera at position (0,0,0) with a node attached in the middle at position (0,0,-20) of the cameras view. Let's say a pointer. The pointer always stays always there. Now what I want is that the camera moves to the pointers position.

How can I get the position of the pointer in world space?

I played around with convertPositon(_:fromNode) (and toNode) but I could not figure out how it works. Is that function the way to go?


Solution

  • I got it, that's the way to go.

    let toPosition = self.pointerNode.convertPosition(self.pointerNode.position, toNode: nil)